diff --git a/problems/kama54.替换数字.md b/problems/kama54.替换数字.md index 0f8daa21..2b3d53de 100644 --- a/problems/kama54.替换数字.md +++ b/problems/kama54.替换数字.md @@ -235,7 +235,15 @@ func main(){ ### python: - +```Python +class Solution: + def change(self, s): + lst = list(s) # Python里面的string也是不可改的,所以也是需要额外空间的。空间复杂度:O(n)。 + for i in range(len(lst)): + if lst[i].isdigit(): + lst[i] = "number" + return ''.join(lst) +``` ### JavaScript: