力扣 344. 反转字符串 C++
解题思路:简单的反转遍历,交换即可
代码:
- class Solution {
- public:
- void reverseString(vector<char>& s) {
- int start=0,end=s.size()-1;
- while(start<end)
- {
- swap(s[start],s[end]);
- start++;
- end--;
- }
- }
- };
推荐阅读