From cb934675e5a0ed1108b9e3eff926e121cb8c8af8 Mon Sep 17 00:00:00 2001 From: Pandurang Lad Date: Wed, 22 Nov 2023 13:09:48 +0530 Subject: [PATCH 1/3] feat: add cs solution to lc problem: No.1424 --- .../1424.Diagonal Traverse II/Solution.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 solution/1400-1499/1424.Diagonal Traverse II/Solution.cs diff --git a/solution/1400-1499/1424.Diagonal Traverse II/Solution.cs b/solution/1400-1499/1424.Diagonal Traverse II/Solution.cs new file mode 100644 index 0000000000000..76d2aac11d158 --- /dev/null +++ b/solution/1400-1499/1424.Diagonal Traverse II/Solution.cs @@ -0,0 +1,16 @@ +public class Solution { + public int[] FindDiagonalOrder(IList> nums) { + List arr = new List(); + for (int i = 0; i < nums.Count; ++i) { + for (int j = 0; j < nums[i].Count; ++j) { + arr.Add(new int[] { i + j, j, nums[i][j] }); + } + } + arr.Sort((a, b) => a[0] == b[0] ? a[1] - b[1] : a[0] - b[0]); + int[] ans = new int[arr.Count]; + for (int i = 0; i < arr.Count; ++i) { + ans[i] = arr[i][2]; + } + return ans; + } +} From b900cc0e7803e16c771c085796232ca2c094ea1e Mon Sep 17 00:00:00 2001 From: Pandurang Lad Date: Wed, 22 Nov 2023 13:11:13 +0530 Subject: [PATCH 2/3] Update README_EN.md to lc problem: No.1424 --- .../1424.Diagonal Traverse II/README_EN.md | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/solution/1400-1499/1424.Diagonal Traverse II/README_EN.md b/solution/1400-1499/1424.Diagonal Traverse II/README_EN.md index 2a907fdc4cb5f..ab7d28368a4d3 100644 --- a/solution/1400-1499/1424.Diagonal Traverse II/README_EN.md +++ b/solution/1400-1499/1424.Diagonal Traverse II/README_EN.md @@ -115,6 +115,27 @@ func findDiagonalOrder(nums [][]int) []int { } ``` +### **C#** + +```cs +public class Solution { + public int[] FindDiagonalOrder(IList> nums) { + List arr = new List(); + for (int i = 0; i < nums.Count; ++i) { + for (int j = 0; j < nums[i].Count; ++j) { + arr.Add(new int[] { i + j, j, nums[i][j] }); + } + } + arr.Sort((a, b) => a[0] == b[0] ? a[1] - b[1] : a[0] - b[0]); + int[] ans = new int[arr.Count]; + for (int i = 0; i < arr.Count; ++i) { + ans[i] = arr[i][2]; + } + return ans; + } +} +``` + ### **...** ``` From 50334dde0dcd8d2ec3baf14b3f0dd9b8da561e7d Mon Sep 17 00:00:00 2001 From: Pandurang Lad Date: Wed, 22 Nov 2023 13:12:03 +0530 Subject: [PATCH 3/3] Update README.md to lc problem: No.1424 --- .../1424.Diagonal Traverse II/README.md | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/solution/1400-1499/1424.Diagonal Traverse II/README.md b/solution/1400-1499/1424.Diagonal Traverse II/README.md index cf236d358f553..5ec5396e50603 100644 --- a/solution/1400-1499/1424.Diagonal Traverse II/README.md +++ b/solution/1400-1499/1424.Diagonal Traverse II/README.md @@ -151,6 +151,27 @@ func findDiagonalOrder(nums [][]int) []int { } ``` +### **C#** + +```cs +public class Solution { + public int[] FindDiagonalOrder(IList> nums) { + List arr = new List(); + for (int i = 0; i < nums.Count; ++i) { + for (int j = 0; j < nums[i].Count; ++j) { + arr.Add(new int[] { i + j, j, nums[i][j] }); + } + } + arr.Sort((a, b) => a[0] == b[0] ? a[1] - b[1] : a[0] - b[0]); + int[] ans = new int[arr.Count]; + for (int i = 0; i < arr.Count; ++i) { + ans[i] = arr[i][2]; + } + return ans; + } +} +``` + ### **...** ```