Sort the Matrix Diagonally (Leetcode 1329)

Опубликовано: 04 Июнь 2026
на канале: Coding Interviews
5,414
75

Amazon, Microsoft, Google, Facebook, Netflix, Apple

Given a m * n matrix mat of integers, sort it diagonally in ascending order from the top-left to the bottom-right then return the sorted array.



Example 1:


Input: mat = [[3,3,1,1],[2,2,1,2],[1,1,1,2]]
Output: [[1,1,1,1],[1,2,2,2],[1,2,3,3]]