Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def solve(arr: list) -> str:
- def reverse(left, right):
- while left < right:
- arr[left], arr[right] = arr[right], arr[left]
- left += 1
- right -= 1
- left = 0
- for right in range(len(arr)):
- if arr[right] == ' ':
- reverse(left, right - 1)
- left = right + 1
- reverse(left, right)
- return "".join(arr)
Advertisement
Add Comment
Please, Sign In to add comment