> For the complete documentation index, see [llms.txt](https://emmaguo100.gitbook.io/leetcode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://emmaguo100.gitbook.io/leetcode/01-15-2022-344.md).

# 01/15/2022 344

using two poniters. left is from the start of the array. right is from the end of the array. While (left < right) swap value and move left pointer to right one step and move the right pointer left step.

Time Space O(N)

Space O(1)

class Solution { public void reverseString(char\[] s) {

```
    //two pointers
    int left = 0, right = s.length - 1;
    
    while(left < right){
            char temp = s[left];
            s[left++] = s[right];
            s[right--] = temp;
        
    }
    
}
```

}
