Bloomberg Coding Interview: Stuttered Letter Cleanup

Based on questions reported for Bloomberg interviews

The interviewer opens

Hi, and thanks for joining. Welcome to your interview for the software engineer role at Bloomberg. We'll work through one coding problem together, and I'd like you to think out loud as you code. If you need to step out or take a break, you can pause the interview any time with the Pause button at the top right.

The problem is about cleaning stuttered letters out of text, and it's in the Problem tab on the right. Please read it through, take your time, and ask me any questions before you start.

The problem

A text-cleaning step strips stuttered letters out of a string.

  • s: a string of lowercase letters.

Find every maximal run of three or more identical consecutive letters in s and remove all of them at once, in a single pass. Letters that become adjacent after the removal are not checked again. Return the remaining string, which may be empty.

Example: s = "aabbbac" → "aaac"

Constraints: 0 ≤ len(s) ≤ 10^5.