Skip to content

Files

Latest commit

May 19, 2024
7a5373a · May 19, 2024

History

History
26 lines (15 loc) · 370 Bytes

problem.md

File metadata and controls

26 lines (15 loc) · 370 Bytes

498. Diagonal Traverse

Given a matrix of M x N elements (M rows, N columns), return all elements of the matrix in diagonal order as shown in the below image.

Example:

Input:
[
 [ 1, 2, 3 ],
 [ 4, 5, 6 ],
 [ 7, 8, 9 ]
]

Output:  [1,2,4,7,5,3,6,8,9]

Explanation:

Note:

The total number of elements of the given matrix will not exceed 10,000.