Question: Common Elements in All Rows of a Matrix [ Difficulty: Easy ] Given an M x N matrix of integers, find the common elements present

Common Elements in All Rows of a Matrix
[Difficulty: Easy]
Given an M x N matrix of integers, find the common elements present in all rows of the given matrix.
Hint: functools module may be useful here.
Input: A list of lists representing the given M x N matrix. There will be M sub-lists in the given list, representing each of the rows. And each list will contain N elements.
Output: A list containing the common element across all the sub-lists of the given list. The output list should be sorted in ascending order. Note that if an element is repeated multiple times across all the rows, it should be counted only once.
Sample Input:
[[1,3,2,3],[4,5,7,2]]
Sample Output:
[2]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!