第3天
字符串(简单)
本题直接调用库函数replace(),无需造轮子
class Solution:
def replaceSpace(self, s: str) -> str:
return s.replace(' ','%20')
没事知识点,直接上code
聪明版:
class Solution:
def reverseLeftWords(self, s: str, n: int) -> str:
return s[n:]+ s[:n]
傻子版:
class Solution:
def reverseLeftWords(self, s: str, n: int) -> str:
a = ''
for i in range(n):
a += s[i]
return s[n:]+a