Erase Pairs

Problem Overview

  • Given a string S, erase any pair of identical letters repeatedly to obtain the shortest possible string.
  • Input: string S; Output: the shortest result after unlimited pair removals; if multiple, return the lexicographically smallest.
  • Domain: string manipulation and text reduction relevant to data cleanup.
  • From Amazon interviews, this interview question is a common coding interview problem.

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: