498. Diagonal Traverse Medium
1/**
2 * [498] Diagonal Traverse
3 *
4 * Given an m x n matrix mat, return an array of all the elements of the array in a diagonal order.
5 *
6 * Example 1:
7 * <img alt="" src="https://assets.leetcode.com/uploads/2021/04/10/diag1-grid.jpg" style="width: 334px; height: 334px;" />
8 * Input: mat = [[1,2,3],[4,5,6],[7,8,9]]
9 * Output: [1,2,4,7,5,3,6,8,9]
10 *
11 * Example 2:
12 *
13 * Input: mat = [[1,2],[3,4]]
14 * Output: [1,2,3,4]
15 *
16 *
17 * Constraints:
18 *
19 * m == mat.length
20 * n == mat[i].length
21 * 1 <= m, n <= 10^4
22 * 1 <= m * n <= 10^4
23 * -10^5 <= mat[i][j] <= 10^5
24 *
25 */
26pub struct Solution {}
27
28// problem: https://leetcode.com/problems/diagonal-traverse/
29// discuss: https://leetcode.com/problems/diagonal-traverse/discuss/?currentPage=1&orderBy=most_votes&query=
30
31// submission codes start here
32
33impl Solution {
34 pub fn find_diagonal_order(mat: Vec<Vec<i32>>) -> Vec<i32> {
35 vec![]
36 }
37}
38
39// submission codes end
40
41#[cfg(test)]
42mod tests {
43 use super::*;
44
45 #[test]
46 fn test_498() {
47 }
48}
49
Back
© 2025 bowen.ge All Rights Reserved.