File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change
1
+ func convert (s string , numRows int ) string {
2
+ if numRows == 1 {
3
+ return s
4
+ }
5
+ length := len (s )
6
+ result := make ([]byte , length )
7
+ step := 2 * numRows - 2
8
+ count := 0
9
+ for i := 0 ; i < numRows ; i ++ {
10
+ for j := 0 ; j + i < length ; j += step {
11
+ result [count ] = s [i + j ]
12
+ count ++
13
+ if i != 0 && i != numRows - 1 && j + step - i < length {
14
+ result [count ] = s [j + step - i ]
15
+ count ++
16
+ }
17
+ }
18
+ }
19
+ return string (result )
20
+ }
Original file line number Diff line number Diff line change 41
41
βΒ Β βββ README.md
42
42
βΒ Β βββ Solution.cpp
43
43
βΒ Β βββ Solution.java
44
+ βΒ Β βββ Solution.go
44
45
βΒ Β βββ Solution.js
45
46
βΒ Β βββ Solution.py
46
47
βββ 0007.Reverse Integer
You canβt perform that action at this time.
0 commit comments