165. Remove Adjacent Duplicates
Core1000 ms256 MBSolved by 0%
Repeatedly remove any two adjacent equal characters until none remain, and print what is left.
In abbaca the bb goes first, leaving aaca; then the aa goes, leaving ca.
Print Empty if the whole string disappears.
Constraints - The line has between 1 and 100000 characters. - Lowercase letters only.
Input
A single line of lowercase letters.
Output
Print what remains after all removals, or Empty if the whole string disappears.
Inputabbaca
Outputca
Noterequires a removal to expose a second one
Inputabcd
Outputabcd
Notehas no adjacent duplicates at all
Hint 1Approach
Hint 2Approach
Hint 3Pseudocode
Hint 4Full solution