Rotate Matrix by 90 Degrees Problem Statement
Given a square matrix 'MATRIX' of non-negative integers, rotate the matrix by 90 degrees in an anti-clockwise direction using only constant extra space.
Input:
The first line of input contains an integer 'T' which represents the number of test cases. Each test case contains:
The first line contains an integer 'N' which is the size of the square matrix 'ARR'.
Each of the following 'N' lines includes 'N' space-separated integers representing the matrix elements.
Output:
For each test case, output the rotated matrix in 'N' lines, where each line displays 'N' space-separated integers. Output should be printed for each test case on separate blocks.
Example:
Input:
1
3
1 2 3
4 5 6
7 8 9
Output:
3 6 9
2 5 8
1 4 7
Constraints:
- 1 ≤ T ≤ 50
- 1 ≤ N ≤ 100
- 1 ≤ MATRIX[i][j] ≤ 105
Note: The implementation of the function should not print anything directly. Focus on computing and returning the results.
Be the first one to answer
Add answer anonymously...
Top Samsung Software Developer Intern interview questions & answers
Popular interview questions of Software Developer Intern
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app