1957: Delete-Characters-to-Make-Fancy-String
Easy
table of contents
Basically just run a sliding window and check if the current letter has been repeated more than 3 times.
code
class Solution {
public:
(string s) {
string makeFancyString{};
string anschar prev{};
int curCounter{1};
for (char& c : s) {
if (c == prev && curCounter < 2) {
+= c;
ans ++curCounter;
} else if (c != prev) {
+= c;
ans = c;
prev = 1;
curCounter }
}
return ans;
}
};