← 返回 meta 的题目列表Diagonal Traverse
类型:online_judge
Given an m x n matrix mat, return an array of all the elements of the array in a diagonal order.
Input Description:
mat: A 2D array of integers representing the matrix.
Output Description:
Return an array containing all the elements in a diagonal order.
Example:
Input: mat = [[1,2,3],[4,5,6],[7,8,9]]
Output: [1,2,4,7,5,3,6,8,9]
Constraints:
The dimensions of m and n are in the range [1, 10^4].
mat[i][j] values are in the range of [-10^5, 10^5].
Example
Input
[[1,2,3],[4,5,6],[7,8,9]]