File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
solution/0000-0099/0006.ZigZag Conversion Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -291,6 +291,18 @@ impl Solution {
291
291
}
292
292
```
293
293
294
+ ``` rust
295
+ impl Solution {
296
+ pub fn convert (s : String , num_rows : i32 ) -> String {
297
+ let num_rows = num_rows as usize ;
298
+ let mut rows = vec! [String :: new (); num_rows ];
299
+ let iter = (0 .. num_rows ). chain ((1 .. num_rows - 1 ). rev ()). cycle ();
300
+ iter . zip (s . chars ()). for_each (| (i , c )| rows [i ]. push (c ));
301
+ rows . into_iter (). collect ()
302
+ }
303
+ }
304
+ ```
305
+
294
306
### ** ...**
295
307
296
308
```
Original file line number Diff line number Diff line change @@ -285,6 +285,18 @@ impl Solution {
285
285
}
286
286
```
287
287
288
+ ``` rust
289
+ impl Solution {
290
+ pub fn convert (s : String , num_rows : i32 ) -> String {
291
+ let num_rows = num_rows as usize ;
292
+ let mut rows = vec! [String :: new (); num_rows ];
293
+ let iter = (0 .. num_rows ). chain ((1 .. num_rows - 1 ). rev ()). cycle ();
294
+ iter . zip (s . chars ()). for_each (| (i , c )| rows [i ]. push (c ));
295
+ rows . into_iter (). collect ()
296
+ }
297
+ }
298
+ ```
299
+
288
300
### ** ...**
289
301
290
302
```
You can’t perform that action at this time.
0 commit comments