forked from luliyucoordinate/Leetcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1324.go
More file actions
29 lines (27 loc) · 620 Bytes
/
Copy path1324.go
File metadata and controls
29 lines (27 loc) · 620 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
func printVertically(s string) []string {
strs := strings.Split(s, " ")
max_len := 0
for _, st := range strs {
max_len = max(max_len, len(st))
}
res := []string{}
for j := 0; j < max_len; j++ {
t, t_len := []byte{}, 0
for _, st := range strs {
if len(st) > j {
t = append(t, st[j])
t_len = len(t)
} else {
t = append(t, ' ')
}
}
res = append(res, string(t[:t_len]))
}
return res
}
func max(a, b int) int {
if a > b {
return a
}
return b
}