Skip to content

Commit bdd0176

Browse files
committed
first commit
1 parent 148c499 commit bdd0176

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

Remove_Consecutive_Duplicates.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Problem Statement
2+
3+
# For a given string (str), remove all the consecutive duplicate characters.
4+
5+
# Example:
6+
# Input String: "aaaa"
7+
# Expected Output: "a"
8+
9+
# Input String: "aabbbcc"
10+
# Expected Output: "abc"
11+
12+
def solve(s):
13+
seen = s[0]
14+
ans = s[0]
15+
for i in s[1:]:
16+
if i != seen:
17+
ans += i
18+
seen = i
19+
return ans
20+
print(solve(input()))

0 commit comments

Comments
 (0)