劍指 Offer 05. 替換空格
阿新 • • 發佈:2020-12-25
技術標籤:劍指offer
https://leetcode-cn.com/problems/ti-huan-kong-ge-lcof/submissions/
func replaceSpace(s string) string { res := make([]byte, 0) for i := 0; i < len(s); i++ { if s[i] == ' ' { res = append(res, "%20"...) } else { res = append(res, s[i]) } } return string(res) }