双指针反转
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; } } };
2023-10-09 15:00:58
双指针反转
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; } } };