pyassistant

Remove Consecutive Duplicate Characters

Given a string s, return a new string where any run of identical consecutive characters is replaced by a single instance of that character. The relative order of characters should be preserved. Examples: - "aaabccc" -> "abc" - "hello" -> "helo" - "" -> "" (empty string remains empty) Write a function solve(s: str) -> str that performs this transformation.

Example:

Input:
('aabbcca',)
Output:
'abca'

Make sure you return your solution, don't print!

AI

Bot

Trying to solve my challenge? Ask if you must, or press the purple button so I can analyze your code.