> For the complete documentation index, see [llms.txt](https://liuyang89116.gitbook.io/my-leetcode-book/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://liuyang89116.gitbook.io/my-leetcode-book/chapter_2_string/problem344_reverse_string.md).

# Problem 344: Reverse String

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

基础题， 这道题的关键在于，学会数组和字符串之间的互相转换

```java
public class Solution {
    public String reverseString(String s) {
        char[] arr = s.toCharArray();
        for (int i = 0; i < arr.length; i++) {
            arr[i] = s.charAt(s.length() - 1 - i);
        }
        return String.valueOf(arr);
    }
}
```

## 易错点

1. 数组元素首尾的对掉`arr[i] = s.charAt(s.length() - 1 - i);`
2. 数组和字符串之间转换
