c++字符串还是不太熟练
class Solution {
public:
bool backspaceCompare(string s, string t) {
return dealString(s) == dealString(t);
}
private:
string dealString(const string& s){
string ret;
int curIndex = 0;
while(curIndex < s.size()){
if(s[curIndex] != '#'){
ret.push_back(s[curIndex]);
}else if(!ret.empty()){
ret.pop_back();
}
++curIndex;
}
return ret;
}
};
标签:844,string,ret,dealString,字符串,curIndex,退格 From: https://www.cnblogs.com/llllmz/p/18403099