LeetCode 344. 反转字符串 Reverse String

LeetCode 344. 反转字符串 Reverse String

 

 双指针反转

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

 

上一篇:vim之复制粘贴


下一篇:[MRCTF2020]Ez_bypass 1