1. 程式人生 > 其它 >劍指 Offer 05. 替換空格

劍指 Offer 05. 替換空格

技術標籤:劍指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)
}