Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 01f1e47

Browse files
feat: add cs solution to lc problem: No.1424 (doocs#1998)
1 parent 2fb53ed commit 01f1e47

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

‎solution/1400-1499/1424.Diagonal Traverse II/README.md‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,27 @@ func findDiagonalOrder(nums [][]int) []int {
151151
}
152152
```
153153

154+
### **C#**
155+
156+
```cs
157+
public class Solution {
158+
public int[] FindDiagonalOrder(IList<IList<int>> nums) {
159+
List<int[]> arr = new List<int[]>();
160+
for (int i = 0; i < nums.Count; ++i) {
161+
for (int j = 0; j < nums[i].Count; ++j) {
162+
arr.Add(new int[] { i + j, j, nums[i][j] });
163+
}
164+
}
165+
arr.Sort((a, b) => a[0] == b[0] ? a[1] - b[1] : a[0] - b[0]);
166+
int[] ans = new int[arr.Count];
167+
for (int i = 0; i < arr.Count; ++i) {
168+
ans[i] = arr[i][2];
169+
}
170+
return ans;
171+
}
172+
}
173+
```
174+
154175
### **...**
155176

156177
```

‎solution/1400-1499/1424.Diagonal Traverse II/README_EN.md‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,27 @@ func findDiagonalOrder(nums [][]int) []int {
115115
}
116116
```
117117

118+
### **C#**
119+
120+
```cs
121+
public class Solution {
122+
public int[] FindDiagonalOrder(IList<IList<int>> nums) {
123+
List<int[]> arr = new List<int[]>();
124+
for (int i = 0; i < nums.Count; ++i) {
125+
for (int j = 0; j < nums[i].Count; ++j) {
126+
arr.Add(new int[] { i + j, j, nums[i][j] });
127+
}
128+
}
129+
arr.Sort((a, b) => a[0] == b[0] ? a[1] - b[1] : a[0] - b[0]);
130+
int[] ans = new int[arr.Count];
131+
for (int i = 0; i < arr.Count; ++i) {
132+
ans[i] = arr[i][2];
133+
}
134+
return ans;
135+
}
136+
}
137+
```
138+
118139
### **...**
119140

120141
```
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
public class Solution {
2+
public int[] FindDiagonalOrder(IList<IList<int>> nums) {
3+
List<int[]> arr = new List<int[]>();
4+
for (int i = 0; i < nums.Count; ++i) {
5+
for (int j = 0; j < nums[i].Count; ++j) {
6+
arr.Add(new int[] { i + j, j, nums[i][j] });
7+
}
8+
}
9+
arr.Sort((a, b) => a[0] == b[0] ? a[1] - b[1] : a[0] - b[0]);
10+
int[] ans = new int[arr.Count];
11+
for (int i = 0; i < arr.Count; ++i) {
12+
ans[i] = arr[i][2];
13+
}
14+
return ans;
15+
}
16+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /