#3446
Sort Matrix by Diagonals
pupil · 415 · lc medium +25 · 84.7% accepted · 510 likes · top 96%
Description
Given an n x n integer matrix grid, reorganize its values so that:
- Each diagonal in the bottom-left half (including the main diagonal) is arranged in non-increasing order.
- Each diagonal in the top-right half is arranged in non-decreasing order.
Return the modified matrix.
Code
1
2
3