344. 反转字符串

llllmz / 2024-10-15 / 原文

 

class Solution {
public:
    void reverseString(vector<char>& s) {
        int head = 0, tail = s.size() -1;
        while(head < tail){
            char temp = s[head];
            s[head] = s[tail];
            s[tail] = temp;
            ++head;
            --tail;
        }
    }
};