6. Z 字形变换
2019.11.06 14:09https://leetcode-cn.com/problems/zigzag-conversion/submissions/
使用语言:Golang
func convert(s string, numRows int) string {
if len(s) <= numRows || numRows == 1 {
return s
}
res := make([]string, numRows)
stepSize := 2 * numRows - 2
for i:=0; i < len(s); i += stepSize {
for j:=0; j<stepSize;j++ {
if i + j >= len(s) {
break
}
if j >= numRows {
res[2*numRows-2-j] += string(s[i+j])
} else {
res[j] += string(s[i+j])
}
}
}
var newS string
for _, sub := range res {
newS += sub
}
return newS
}这道题目没什么难度,只要找到规律,程序很好写。
IDENTITY //
痕迹
没有过去,就没法认定现在的自己
