2109. Adding Spaces to a String
Содержание
class Solution:
def addSpaces(self, s: str, spaces: List[int]) -> str:
res = []
i, j = len(s) - 1, len(spaces) - 1
while i >= 0:
res.append(s[i])
if j >= 0 and i == spaces[j]:
res.append(' ')
j -= 1
i -= 1
return ''.join(res[::-1])