FazeelUsmani / Amazon-SDE-Preparation

This repository includes all the interview preparation questions for Amazon SDE role
https://practice.geeksforgeeks.org/batch/Amazon-Test-Series
1.12k stars 291 forks source link

04 Matrix -> 06 Unique rows in boolean matrix #23

Closed FazeelUsmani closed 3 years ago

FazeelUsmani commented 3 years ago
  1. Unique rows in boolean matrix Easy Accuracy: 39.61% Submissions: 8416 Points: 2 Given a binary matrix your task is to find all unique rows of the given matrix.

Example 1:

Input: row = 3, col = 4 M[][] = {{1 1 0 1},{1 0 0 1},{1 1 0 1}} Output: 1 1 0 1 $1 0 0 1 $ Explanation: Above the matrix of size 3x4 looks like 1 1 0 1 1 0 0 1 1 1 0 1 The two unique rows are 1 1 0 1 and 1 0 0 1 . Your Task: You only need to implement the given function uniqueRow(). The function takes three arguments the first argument is a matrix M and the next two arguments are row and col denoting the rows and columns of the matrix. The function should return the list of the unique row of the martrix. Do not read input, instead use the arguments given in the function.

Note: The drivers code print the rows "$" separated.

Expected Time Complexity: O(row col) Expected Auxiliary Space: O(row col)

Constraints: 1<=row,col<=40 0<=M[][]<=1