> For the complete documentation index, see [llms.txt](https://rachel2011.gitbook.io/leetcode_cc150/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rachel2011.gitbook.io/leetcode_cc150/two-pointers/reverse-string.md).

# Reverse String

Write a function that takes a string as input and returns the string reversed.

**Example:**\
Given s = "hello", return "olleh".

```
class Solution(object):
    def reverseString(self, s):
        """
        :type s: str
        :rtype: str
        """
        """
        return s[::-1]
        """
        l = list(s)
        start = 0
        end = len(l)-1
        while start < end:
            l[start],l[end] = l[end],l[start]
            start += 1
            end -= 1
        return ''.join(l)
```

```
class Solution(object):
    def reverseString(self, s):
        l = len(s)
        if l < 2:
            return s
        return self.reverseString(s[l/2:]) + self.reverseString(s[:l/2])
```
