关注我,分享高质量每日一题题解~
b站同名账号分享力扣杯历届真题视频题解,也欢迎大家提出宝贵意见!
思路:模拟
- 思路参见 3640. 删除字符串 题解,比较时比较所有 $8$ 种情况即可
代码(C++)
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
int n = s.size();
string ret = "";
for(int i = 0; i < n; i++) {
string t = s.substr(i, 3);
if(t == "gzu" || t == "Gzu" || t == "gZu" || t == "gzU" || t == "GZu" || t == "GzU" || t == "gZU" || t == "GZU") {
i = i + 2;
} else {
ret += s[i];
}
}
cout << ret;
return 0;
}