leetcode 344. 反转字符串

leetcode

C++:

class Solution {
public:
    void reverseString(vector& s) {
        
        int left = 0;
        int right = s.size() - 1;
        while ( left < right ) {

            auto temp = s[left];
            s[left] = s[right];
            s[right] = temp;

            ++left;
            --right;
        }
    }
};

你可能感兴趣的:(leetcode 344. 反转字符串)