leetcode.com/problems/backspace-string-compare/
class Solution {
public:
bool backspaceCompare(string S, string T) {
int sizes = S.size();
int sizet = T.size();
while(S.find('#') != -1){
if(S.find('#') == 0){
S.erase(S.find('#'), 1);
}
else{
S.erase(S.find('#') -1, 2);
}
}
while(T.find('#') != -1){
if(T.find('#') == 0){
T.erase(T.find('#'), 1);
}
else{
T.erase(T.find('#') -1, 2);
}
}
if(S == T){
return true;
}
return false;
}
};
'알고리즘 문제풀이 > LeetCode' 카테고리의 다른 글
LeetCode 13번 - Roman to Integer (0) | 2020.07.28 |
---|---|
LeetCode 686번- Repeated String Match (0) | 2020.07.28 |
LeetCode 67번 - Add Binary (0) | 2020.07.28 |
LeetCode 14번 - Longest Common Prefix (0) | 2020.07.28 |
LeetCode 81번 - Search in Rotated Sorted Array II (0) | 2020.07.27 |