File tree Expand file tree Collapse file tree 3 files changed +58
-0
lines changed
solution/1400-1499/1424.Diagonal Traverse II Expand file tree Collapse file tree 3 files changed +58
-0
lines changed Original file line number Diff line number Diff 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```
Original file line number Diff line number Diff 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```
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments