Leetcode 344 Solution

This article provides solution to leetcode question 344 (reverse-string)

https://leetcode.com/problems/reverse-string

Solution

class Solution:
    def reverseString(self, s: List[str]) -> None:
        """
        Do not return anything, modify s in-place instead.
        """
        def dfs(s, i, j):
            if i >= j:
                return
            s[i], s[j] = s[j], s[i]
            dfs(s, i + 1, j - 1)
        dfs(s, 0, len(s) - 1)