Problem statement

https://binarysearch.com/problems/Compress-String/

Solution

We can use groupby here.

Complexity

It is O(n) for time and space.

Code

class Solution:
    def solve(self, s):
        return "".join(i for i, j in groupby(s))