[
string
groupby
]
BinarySearch 0139 Consecutive Duplicates
Problem statement
https://binarysearch.com/problems/Consecutive-Duplicates/
Solution
Just use groupby and choose one element from each group.
Complexity
It is O(n)
for time and space.
Code
class Solution:
def solve(self, s):
return ("".join(x for x, y in groupby(s)))