Skip to content

Commit 7b17ad8

Browse files
committed
Jul 21
1 parent 0cfdf46 commit 7b17ad8

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
class Solution:
2+
def makeFancyString(self, s: str) -> str:
3+
prev_char, curr_count = None, 0
4+
result = ''
5+
for ch in s:
6+
if ch == prev_char:
7+
curr_count += 1
8+
else:
9+
curr_count = 1
10+
if curr_count < 3:
11+
result += ch
12+
prev_char = ch
13+
return result
14+
15+
16+
def main():
17+
s = 'leeetcode'
18+
assert Solution().makeFancyString(s) == 'leetcode'
19+
20+
s = 'aaabaaaa'
21+
assert Solution().makeFancyString(s) == 'aabaa'
22+
23+
s = 'aab'
24+
assert Solution().makeFancyString(s) == 'aab'
25+
26+
27+
if __name__ == '__main__':
28+
main()

2025-07-July-LeetCoding-Challenge/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
| July 17 | [3202. Find the Maximum Length of Valid Subsequence II](https://leetcode.com/problems/find-the-maximum-length-of-valid-subsequence-ii/) | Medium | Unsolved |
2424
| July 18 | [2163. Minimum Difference in Sums After Removal of Elements](https://leetcode.com/problems/minimum-difference-in-sums-after-removal-of-elements/) | Hard | Unsolved |
2525
| July 19 | [1233. Remove Sub-Folders from the Filesystem](https://leetcode.com/problems/remove-sub-folders-from-the-filesystem/) | Medium | Solved |
26-
| July 20 | []() | | |
27-
| July 21 | []() | | |
26+
| July 20 | [1948. Delete Duplicate Folders in System](https://leetcode.com/problems/delete-duplicate-folders-in-system/) | Hard | Unsolved |
27+
| July 21 | [1957. Delete Characters to Make Fancy String](https://leetcode.com/problems/delete-characters-to-make-fancy-string/) | Easy | Solved |
2828
| July 22 | []() | | |
2929
| July 23 | []() | | |
3030
| July 24 | []() | | |
@@ -40,6 +40,6 @@
4040
## Summary
4141
| Level | Problems | Solved | Unsolved |
4242
| --- | --- | --- | --- |
43-
| Easy | 5 | 5 | 0 |
43+
| Easy | 6 | 6 | 0 |
4444
| Medium | 8 | 7 | 1 |
45-
| Hard | 6 | 1 | 5 |
45+
| Hard | 7 | 1 | 6 |

0 commit comments

Comments
 (0)