Dsa
Matrix
Easy
Flipping a Matrix
You are given a matrix of size m x n. Your task is to flip the matrix vertically (i.e., reverse the order of the rows). Write a program to perform this operation.
Input Format:
The first line contains two integers m and n (1 <= m, n <= 100).
Each of the next m lines contains n space-separated integers representing the elements of the matrix.
Output Format:
Print the flipped matrix with each row on a new line and elements separated by space.
Example:
Input:
3 3
1 2 3
4 5 6
7 8 9
Output:
7 8 9
4 5 6
1 2 3
Key concepts
matrixflippingtransformation
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