Error
|
|
---|---|
@Ibrahim Nash | 6420 |
@blackshadows | 6376 |
@mb1973 | 5604 |
@Quandray | 5231 |
@akhayrutdinov | 5111 |
@saiujwal13083 | 4510 |
@sanjay05 | 3762 |
@kirtidee18 | 3673 |
@marius_valentin_dragoi | 3522 |
@sushant_a | 3459 |
@verma_ji | 3413 |
Complete Leaderboard | |
|
|
@codersgroup18 | 799 |
@sriramgoparaju99 | 737 |
@Manikanta punnam | 629 |
@rdakka | 606 |
@prankursharma31 | 597 |
@praveenbgp6 | 546 |
@sanskar94511 | 531 |
@purohitmn02 | 525 |
@yashkaril4 | 517 |
@abhikarshgupta | 474 |
@rohitgarg2825 | 464 |
Complete Leaderboard |
Given a square matrix of size N x N. The task is to rotate it by 90 degrees in anti-clockwise direction without using any extra space.
Example 1:
Input:
N = 3
matrix[][] = {{1, 2, 3},
{4, 5, 6}
{7, 8, 9}}
Output:
Rotated Matrix:
3 6 9
2 5 8
1 4 7
Example 2:
Input:
N = 2
matrix[][] = {{1, 2},
{3, 4}}
Output:
Rotated Matrix:
2 4
1 3
Your Task:
You dont need to read input or print anything. Complete the function rotateby90() which takes the matrix as input parameter and rotates it by 90 degrees in anti-clockwise direction without using any extra space. You have to modify the input matrix in-place.
Expected Time Complexity: O(N2)
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ N ≤ 100
1 <= matrix[][] <= 1000
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Yes