Transform String

Problem Overview

  • Given a string S of A, B, C, and D, remove adjacent pairs A with B or C with D repeatedly until no more removals are possible, and return the resulting string.
  • Input: S with length 0 to 250,000 using only A, B, C, D; Output: any valid irreducible string.
  • Domain: string processing and reduction where specified adjacent patterns are eliminated.
  • From Janestreet interviews, this coding interview problem is an interview question with multiple valid outcomes.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: