Skip to content

Commit 4fff2fe

Browse files
authored
Create 1957. Delete Characters to Make Fancy String1 (#845)
2 parents 25406f4 + 43ed64b commit 4fff2fe

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
class Solution {
2+
public:
3+
string makeFancyString(string s) {
4+
int n = s.length();
5+
int count = 1;
6+
string res = "";
7+
res += s[0];
8+
9+
for(int i=1; i<n; i++){
10+
if(s[i] == s[i-1]){
11+
count++;
12+
}else{
13+
count = 1;
14+
}
15+
if(count < 3){
16+
res += s[i];
17+
}
18+
}
19+
return res;
20+
}
21+
};

0 commit comments

Comments
 (0)