Remove All Adjacent Repeated Runs Until Stable

Quick Overview

Remove entire repeated-character runs until stable, with explicit simultaneous-round semantics, cascading examples, a correct baseline, and optimization trade-offs.

Remove All Adjacent Repeated Runs Until Stable

Company: Whatnot

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

Remove adjacent runs containing two or more equal characters, then continue removing repeated runs created by earlier deletions until the string is stable. Unlike pair cancellation, a run of three equal characters is removed completely. ### Constraints & Assumptions The source describes deleting all repeated characters without a fixed k. For this practice version, each round removes every maximal run of length at least two simultaneously, then repeats. Confirm this policy because a left-to-right immediate-removal rule can differ. ### Clarifying Questions to Ask - Are all runs in one round removed simultaneously? - Should new runs exposed by deletions be removed in later rounds? ```hint Preserve run boundaries within a round Do not let characters that were separated at the start of the round alter which original runs are removed in that same round. ``` ### What a Strong Answer Covers - Detecting maximal equal-character runs and dropping the whole run. - Repeating until no deletion occurs under the stated round semantics. - Correctness and the worst-case cost of repeated scans. ### Follow-up Questions - How could linked run nodes and an affected-neighbor queue avoid rescanning the entire string? - Give an input where pair cancellation differs from whole-run deletion.

Overview: Remove entire repeated-character runs until stable, with explicit simultaneous-round semantics, cascading examples, a correct baseline, and optimization trade-offs.

Read the full Whatnot Software Engineer interview experience this question came from

Whatnot logo
Whatnot
Feb 9, 2026
mediumSoftware EngineerTechnical ScreenCoding & Algorithms
1
0

Remove adjacent runs containing two or more equal characters, then continue removing repeated runs created by earlier deletions until the string is stable. Unlike pair cancellation, a run of three equal characters is removed completely.

Constraints & Assumptions

The source describes deleting all repeated characters without a fixed k. For this practice version, each round removes every maximal run of length at least two simultaneously, then repeats. Confirm this policy because a left-to-right immediate-removal rule can differ.

Clarifying Questions to Ask Guidance

  • Are all runs in one round removed simultaneously?
  • Should new runs exposed by deletions be removed in later rounds?

What a Strong Answer Covers Guidance

  • Detecting maximal equal-character runs and dropping the whole run.
  • Repeating until no deletion occurs under the stated round semantics.
  • Correctness and the worst-case cost of repeated scans.

Follow-up Questions Guidance

  • How could linked run nodes and an affected-neighbor queue avoid rescanning the entire string?
  • Give an input where pair cancellation differs from whole-run deletion.