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