Medium Accuracy: 65.01%
Submissions: 4637 Points: 4
Given an NxM 2D matrix, rearrange such that
Each diagonal in the lower left triangle of the rectangular grid is sorted in ascending order.
Each diagonal in the upper right triangle of the rectangular grid is sorted in descending order.
The major diagonal in the grid starting from the top-left corner is not rearranged.
You don't need to read input or print anything. Your task is to complete the function diagonalSort() which takes the matrix, n and m as input parameter and rearranges the elements of the matrix.
Expected Time Complexity: O(NxM) Expected Auxiliary Space: O(N+M)