Inplace rotate matrix 90 degree
You are given a square matrix of non-negative integers of size 'N x N'. Your task is to rotate that array by 90 degrees in an anti-clockwise direction without using any extra space.
For example:
For given 2D array :
[ [ 1, 2, 3 ],
[ 4, 5, 6 ],
[ 7, 8, 9 ] ]
After 90 degree rotation in anti clockwise direction, it will become:
[ [ 3, 6, 9 ],
[ 2, 5, 8 ],
[ 1, 4, 7 ] ]
Input Format :
The first line of input contains an integer 'T' representing the number of the test case. Then the test case follows.
The first line of each test case contains an integer 'N' representing the size of the square matrix ARR.
Each of the next 'N' lines contains 'N' space-separated integers representing the elements of the matrix 'ARR'.
Output Format:
For each test case, return the rotated matrix.
Note:
You do not need to print anything; it has already been taken care of. Just implement the given function.
Constraints:
1 ≤ T ≤ 50
1 ≤ N ≤ 100
1 ≤ ARR[i][j] ≤ 10^9
Time Limit: 1 sec
Be the first one to answer
Add answer anonymously...
Top Jaguar Land Rover Software Developer interview questions & answers
Popular interview questions of Software Developer
>
Jaguar Land Rover Software Developer Interview Questions
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