344.反转字符串
代码:
1 void reverseString(vector<char>& s) { 2 3 int i = 0; 4 int j = s.size() - 1; 5 while (i < j) 6 { 7 char mid = s[i]; 8 s[i] = s[j]; 9 s[j] = mid; 10 11 i++; 12 j--; 13 } 14 }
1 void reverseString(vector<char>& s) { 2 3 int i = 0; 4 int j = s.size() - 1; 5 while (i < j) 6 { 7 char mid = s[i]; 8 s[i] = s[j]; 9 s[j] = mid; 10 11 i++; 12 j--; 13 } 14 }