原文链接:https://leetcode-cn.com/problems/reverse-string/
双指针法
void reverseString(vector
<char>& s
) {
int n
=s
.size();
for(int i
=0,j
=n
-1;i
<j
;i
++,j
--){
char tmp
=s
[i
];
s
[i
]=s
[j
];
s
[j
]=tmp
;
}
}
转载请注明原文地址:https://tech.qufami.com/read-14469.html