Skip to content

Instantly share code, notes, and snippets.

@icameling
Created July 19, 2022 03:39
Show Gist options
  • Select an option

  • Save icameling/0c364f7a9273e52bb936406066e60147 to your computer and use it in GitHub Desktop.

Select an option

Save icameling/0c364f7a9273e52bb936406066e60147 to your computer and use it in GitHub Desktop.
#字符串 #反转字符串
class Solution {
public:
void reverseString(vector<char>& s) {
int left = 0, right = s.size() - 1;
while (left < right) {
char tmp = s[left];
s[left] = s[right];
s[right] = tmp;
left++;
right--;
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment