#3446
Sort Matrix by Diagonals
medium · 84.7% accepted · 510 likes · top 96%
Description
You are given an n x n square matrix of integers grid. Return the matrix such that:
- The diagonals in the bottom-left triangle (including the middle diagonal) are sorted in non-increasing order.
- The diagonals in the top-right triangle are sorted in non-decreasing order.
Solution