DEV Community

loading...

Discussion on: Daily Challenge #259 - Duplicate Encoder

Collapse
jingxue profile image
Jing Xue • Edited

Python:



from collections import Counter


def duplicate_encoder(s: str) -> str:
    all_lower = s.lower()
    counter = Counter(all_lower)
    return ''.join([')' if counter.get(c) > 1 else '(' for c in all_lower])