Given a binary matrix whose elements are only 0 and 1, we need to print the rows which are duplicate of rows which are already present in the matrix.
Input : [[1, 1, 0, 1, 0, 1], [0, 0, 1, 0, 0, 1], [1, 0, 1, 1, 0, 0], [1, 1, 0, 1, 0, 1], [0, 0, 1, 0, 0, 1], [0, 0, 1, 0, 0, 1]] Output : (1, 1, 0, 1, 0, 1) (0, 0, 1, 0, 0, 1)
- Create a dictionary using counter method which will have rows as key and it’s frequency as value.
- Now traverse dictionary completely and print all rows which have frequency greater than 1.
(1, 1, 0, 1, 0, 1) (0, 0, 1, 0, 0, 1)
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.
- Python - Counter.items(), Counter.keys() and Counter.values()
- Find duplicate rows in a binary matrix
- Python program to remove rows with duplicate element in Matrix
- Find duplicate rows in a Dataframe based on all or selected columns
- Python - Matrix elements Frequencies Counter
- Print a given matrix in counter-clock wise spiral form
- Find pair of rows in a binary matrix that has maximum bit difference
- Using Counter() in Python to find minimum character removal to make two strings anagram
- Dictionary and counter in Python to find winner of election
- Python Counter to find the size of largest subset of anagram words
- Check if the rows of a binary matrix can be made unique by removing a single column
- Anagram checking in Python using collections.Counter()
- Python dictionary, set and counter to check if frequencies can become same
- Python counter and dictionary intersection example (Make a string using deletion and rearrangement)
- Python | Minimum number of subsets with distinct elements using Counter
- Python Counter | Majority Element
- Python | Counter Objects | elements()
- Operations on Python Counter
- Python | Case Counter in String
- Python - Occurrence counter in List of Records
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.