Skip to content

Commit c8a50d3

Browse files
committed
Time: 15 ms (100.00%), Space: 45.5 MB (63.92%) - LeetHub
1 parent 03237c9 commit c8a50d3

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution {
2+
public String makeFancyString(String s) {
3+
char[] a = s.toCharArray();
4+
int i = 1;
5+
for (int j = 1, count = 1; j < a.length; j++) {
6+
count = a[j] == a[j - 1] ? count + 1 : 1;
7+
if (count < 3)
8+
a[i++] = a[j];
9+
}
10+
return new String(a, 0, i);
11+
}
12+
}

0 commit comments

Comments
 (0)