Reverse Rows of a Matrix Problem Statement

You are given a matrix and tasked with reversing the order of elements in each row. This needs to be done for every row in the matrix.

Help a participant named Ninja, who is new to programming, solve this problem by reversing all rows of the given matrix.

Example:

Input:
T = 1
N = 3, M = 3
Matrix:
1 2 3
4 5 6
7 8 9
Output:
3 2 1
6 5 4
9 8 7
Explanation:

Each row of the matrix is reversed, turning [1, 2, 3] into [3, 2, 1], [4, 5, 6] into [6, 5, 4], and [7, 8, 9] into [9, 8, 7].

Constraints:

  • 1 <= T <= 50
  • 1 <= N <= 400
  • 1 <= M <= 400
  • 0 <= MAT[i][j] <= 100
  • Time Limit: 1 sec
AnswerBot
4mo

Reverse the order of elements in each row of a given matrix.

  • Iterate through each row of the matrix

  • Reverse the elements in each row

  • Return the modified matrix

Help your peers!
Select
Add answer anonymously...

Jio Platforms Backend Developer interview questions & answers

A Backend Developer was asked Q. How do you reverse a matrix?
A Backend Developer was asked Q. Aggregate query on mysql. Difference between sql and nosql databases.
A Backend Developer was asked Q. Reverse Rows of a Matrix Problem Statement You are given a matrix and tasked wit...read more

Popular interview questions of Backend Developer

A Backend Developer was asked Q1. How do you reverse a matrix?
A Backend Developer was asked Q2. Aggregate query on mysql. Difference between sql and nosql databases.
A Backend Developer was asked Q3. Reverse Rows of a Matrix Problem Statement You are given a matrix and tasked wit...read more
Jio Platforms Backend Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits