FunctionRacerProblemsRace

Delete Characters to Make Fancy String

EasyStringsPython, JavaScript, TypeScript, Java, C++

A fancy string has no three equal characters in a row. Delete the fewest characters from s to make it fancy: in every run of equal characters, keep only the first two. Return the result.

Example 1

s "leeetcode"
returns "leetcode"

Three e become two: leetcode.

Example 2

s "aaabaaaa"
returns "aabaa"

Runs aaa and aaaa shrink to aa: aabaa.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Strings problems