Dsa
Matrix
Easy
Max Element in Each Row
Find the maximum element in each row of a given matrix and return them as a list.
Input Format:
The first line contains two integers M and N, the number of rows and columns.
The next M lines each contain N integers representing the elements of the matrix.
Output Format:
Print a space-separated list of maximum elements from each row.
Example:
Input:
3 3
1 2 3
4 5 6
7 8 9
Output:
3 6 9
Key concepts
matrixmaxrows
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