Print unique rows in a given boolean matrix | Given a binary matrix of M X N of integers , you need to return only unique rows of binary array ; Function that prints all unique rows in a given matrix . ; Traverse through the matrix ; Check if there is similar column is already printed , i . e if i and jth column match . ; If no row is similar ; Print the row ; Driver Code
let ROW = 4 ; let COL = 5 ; function findUniqueRows ( M ) { for ( let i = 0 ; i < ROW ; i ++ ) { let flag = 0 ; for ( let j = 0 ; j < i ; j ++ ) { flag = 1 ; for ( let k = 0 ; k < COL ; k ++ ) if ( M [ i ] [ k ] != M [ j ] [ k ] ) flag = 0 ; if ( flag == 1 ) break ; } if ( flag == 0 ) { for ( let j = 0 ; j < COL ; j ++ ) document . write ( M [ i ] [ j ] + " " ) ; document . write ( " " ) ; } } } let M = [ [ 0 , 1 , 0 , 0 , 1 ] , [ 1 , 0 , 1 , 1 , 0 ] , [ 0 , 1 , 0 , 0 , 1 ] , [ 1 , 0 , 1 , 0 , 0 ] ] findUniqueRows ( M )