Dsa
Matrix
Easy
Row Maximum and Minimum
Given a 2D matrix of integers, return the maximum and minimum value for each row.
Input format:
- The first line contains two integers, M and N, indicating the number of rows and columns.
- The next M lines each contain N integers representing the matrix elements.
Output format:
- Each line should contain the maximum and minimum value for the respective row, separated by a space.
Example:
Input:
3 3
1 2 3
4 5 6
7 8 9
Output:
3 1
6 4
9 7
Key concepts
matrixrow operationscomparison
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