![]() |
VOOZH | about |
Given a square matrix, swap upper diagonal elements of matrix with lower diagonal elements of matrix.
Examples :
Input: 2 3 5 6 4 5 7 9 8 6 4 9 1 3 5 6 Output: 2 4 8 1 3 5 6 3 5 7 4 5 6 9 9 6 Input: 1 2 3 4 5 6 7 8 9 Output: 1 4 7 2 5 8 3 6 9
Below is the implementation of above idea :
2 4 8 1 3 5 6 3 5 7 4 5 6 9 9 6
Time Complexity: O(N2)
Auxiliary Space: O(1)