Tap here to switch tabs
Problem
Ask
Submissions

Problem: Diagonal Traverse

med
30 min
Explore the diagonal traversal of matrices by learning to navigate elements in alternating upward-right and downward-left directions. Understand the core logic to implement this efficient matrix traversal method, helping you solve related coding interview problems with clarity.

Statement

Given an m×nm \times n integer matrix mat, return a list containing all elements of mat traversed in diagonal order.

In diagonal traversal, the diagonals alternate between moving upward-right and downward-left across the matrix, visiting every element exactly once.

Constraints:

  • m ==== mat.length

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

  • 11 \leq m, n 104\leq 10^4

  • 11 \leq m * n 104\leq 10^4

  • 105-10^5 \leq mat[i][j] 105\leq 10^5

Tap here to switch tabs
Problem
Ask
Submissions

Problem: Diagonal Traverse

med
30 min
Explore the diagonal traversal of matrices by learning to navigate elements in alternating upward-right and downward-left directions. Understand the core logic to implement this efficient matrix traversal method, helping you solve related coding interview problems with clarity.

Statement

Given an m×nm \times n integer matrix mat, return a list containing all elements of mat traversed in diagonal order.

In diagonal traversal, the diagonals alternate between moving upward-right and downward-left across the matrix, visiting every element exactly once.

Constraints:

  • m ==== mat.length

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

  • 11 \leq m, n 104\leq 10^4

  • 11 \leq m * n 104\leq 10^4

  • 105-10^5 \leq mat[i][j] 105\leq 10^5