class Solution {
public:
void reverseString(vector<char>& s) {
// 直接前后交换就好了,start++前进,end--后退
if(s.size()==0) return;
int start=0,end=s.size()-1;
char temp;
while(start<end){
temp=s[start];
s[start]=s[end];
s[end]=temp;
start++;
end--;
}
}
};
LeetCode每日一题 (35) 344. 反转字符串(易)
猜你喜欢
转载自blog.csdn.net/qq_45021180/article/details/108966436
今日推荐
周排行