SOLUTION INFO
C++ · main.cpp
class Solution {
public:
string makeFancyString(string s) {
char pre = -1;
int cnt = 0, j = 0;
for(int i = 0; i < s.size(); ++i) {
char ch = s[i];
if(pre == ch) {
if(++ cnt >= 3) continue;
s[j ++] = ch;
}
else {
pre = ch;
cnt = 1;
s[j ++] = ch;
}
}
return s.substr(0, j);
}
};
SOLUTION DESCRIPTION
풀이 설명
등록된 풀이 설명이 없습니다.