# 344. Reverse String

**<font color=red>难度: Easy</font>**

## 刷题内容

> 原题连接

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

> 内容描述

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

Example 1:

Input: "hello"
Output: "olleh"
Example 2:

Input: "A man, a plan, a canal: Panama"
Output: "amanaP :lanac a ,nalp a ,nam A"
```

## 解题方案

> 思路 1
******- 时间复杂度: O(N)******- 空间复杂度: O(N)******

因为python不支持item assignment

所以如果非要用two pointer来做的话，那么会是这样

```python
class Solution(object):
    def reverseString(self, s):
        """
        :type s: str
        :rtype: str
        """
        lst = list(s)
        start, end = 0, len(lst) - 1

        while start < end:
            lst[end], lst[start] = lst[start], lst[end]
            start += 1
            end -= 1
        return ''.join(lst)
```



> 思路 2
******- 时间复杂度: O(N)******- 空间复杂度: O(1)******

不要脸的python AC code:


```python
class Solution(object):
    def reverseString(self, s):
        """
        :type s: str
        :rtype: str
        """
        return s[::-1]
```
