Given a matrix of characters containing only lowercase letters, form a new string from the matrix that remain after removing the duplicate characters from each row and column. The remaining characters are joined row-wise to form the string.
Input : Matrix of characters (Or array of strings) aabcd effgh iijkk lmnoo pqqrs ttuvw xxyyz Output : bcdeghjlmnprsuvwz The characters that appear more than once in their row or column are removed. Input : zx xz Output :zxxz
Approach : Traverse the entire matrix and for every element, check its corresponding row and column. If there are duplicates, then mark that particular cell in another matrix as true. Finally, all the characters for which there is false value in another matrix are joined to form the string.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Count Negative Numbers in a Column-Wise and Row-Wise Sorted Matrix
- Count zeros in a row wise and column wise sorted matrix
- Sort the matrix row-wise and column-wise
- Row-wise vs column-wise traversal of matrix
- Largest row-wise and column-wise sorted sub-matrix
- Maximum sum of any submatrix of a Matrix which is sorted row-wise and column-wise
- Search in a row wise and column wise sorted matrix
- Count number of islands where every island is row-wise and column-wise separated
- Check if a grid can become row-wise and column-wise sorted after adjacent swaps
- Kth smallest element in a row-wise and column-wise sorted 2D array | Set 1
- Print all elements in sorted order from row and column wise sorted matrix
- heapq in Python to print all elements in sorted order from row and column wise sorted matrix
- Check if the given matrix is increasing row and column wise
- Leftmost Column with atleast one 1 in a row-wise sorted binary matrix
- Leftmost Column with atleast one 1 in a row-wise sorted binary matrix | Set 2
- Find trace of matrix formed by adding Row-major and Column-major order of same matrix
- Check if a given matrix can be converted to another given matrix by row and column exchanges
- Find a common element in all rows of a given row-wise sorted matrix
- Row-wise common elements in two diagonals of a square matrix
- Shift matrix elements row-wise by k
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.