leetcode 344 翻转字符串

就这?

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

 

posted @ 2021-03-07 17:13  zhaohhhh  阅读(33)  评论(0)    收藏  举报