Dsa
Matrix
Warm-up
Find Unique Elements in Matrix
Given a 2D matrix, find all unique elements across all rows of the matrix and return them as a sorted list.
Input format:
- The first line contains two integers M and N, the dimensions of the grid.
- The next M lines contain N integers each, representing the grid.
Output format:
- Print the sorted list of unique elements.
Example:
Input:
2 3
1 2 3
3 2 1
Output:
1 2 3
Key concepts
matrixset operations
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now