Leetcode # 344. Reverse String
Problem
https://leetcode.com/problems/reverse-string
Solution
Time Complexity: O(n)
Space Complexity: O(1)
(The input and output generally do not count towards the space complexity.)
class Solution: def reverseString(self, s: List[str]) -> None: """ Do not return anything, modify s in-place instead. """ for i in range(len(s) // 2): s[i], s[len(s) - i - 1] = s[len(s) - i - 1], s[i]
Last Updated on 2023/08/24 by A1go