Tap here to switch tabs
Problem
Submissions

Problem: Sort the Matrix Diagonally

med
30 min
Try to solve the Sort the Matrix Diagonally problem.

Statement

A matrix diagonal is a diagonal line of cells starting from some cell in either the topmost row or leftmost column and going in the bottom right direction until reaching the edge of the matrix.

Given an m×nm \times n integer matrix mat, sort each matrix diagonal in ascending order and return the resulting matrix.

Constraints:

  • m ==== mat.length

  • n ==== mat[i].length

  • 1≤1 \leq m, n ≤100\leq 100

  • 1≤1 \leq mat[i][j] ≤100\leq 100

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Sort the Matrix Diagonally

med
30 min
Try to solve the Sort the Matrix Diagonally problem.

Statement

A matrix diagonal is a diagonal line of cells starting from some cell in either the topmost row or leftmost column and going in the bottom right direction until reaching the edge of the matrix.

Given an m×nm \times n integer matrix mat, sort each matrix diagonal in ascending order and return the resulting matrix.

Constraints:

  • m ==== mat.length

  • n ==== mat[i].length

  • 1≤1 \leq m, n ≤100\leq 100

  • 1≤1 \leq mat[i][j] ≤100\leq 100