Search
⌘K

Leetcode 1329. Sort the Matrix Diagonally

Given an m x n integer matrix, sort the elements along each top-left to bottom-right diagonal independently in ascending order and return the resulting matrix. A useful observation is that cells on the same diagonal share the same i-j index, so you can group and reorder each diagonal separately (m,n ≤ 100, values 1..100).

Asked at:

Meta


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Early June, 2025

Meta

Senior

Comments

Your account is free and you can post anonymously if you choose.