Skip to content

Commit 0972c9c

Browse files
committed
Time: 47 ms (10.25%), Space: 42.8 MB (63.06%) - LeetHub
1 parent 39fff37 commit 0972c9c

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution {
2+
public:
3+
string makeFancyString(string s) {
4+
string ans;
5+
for (int i = 0; i < s.size(); i++) {
6+
if (ans.size() > 1) {
7+
if (s[i] == ans[ans.size() - 1] && s[i] == ans[ans.size() - 2]) continue;
8+
ans += s[i];
9+
} else {
10+
ans += s[i];
11+
}
12+
}
13+
return ans;
14+
}
15+
};

0 commit comments

Comments
 (0)