2dbi
Home/Miro/Remove All Adjacent Duplicates in String
MMiro·DSASWE-2Technical Phone Screen

Remove All Adjacent Duplicates in String

Problem

Repeatedly remove adjacent equal characters until none remain; return the result.

Example

"abbaca" -> "ca"

Constraints

  • 1 ≤ |s| ≤ 10^5

Approach

Stack: pop on match, else push. Reported Miro question.

added 6 days ago
LeadersAccount