The TransCompilator

Solved LeetCode program · 809 of 1,000

#1047 · Remove All Adjacent Duplicates In String

Easy String chunk-17.md

Original English source

The source is "abbaca". The kept is empty text. The held is 0.
For every spot from 0 to the last position of source.
The symbol is character spot of source. The top is 0. If held is more than 0, set top to character (held minus 1) of kept. The removed is 0. If held is more than 0 and top is symbol, remove last character from kept, subtract 1 from held, set removed to 1. If removed is 0, Place symbol into kept, add 1 to held.

Show kept.

Open in Playground Browse all 1,000 problems

Expected stdout

ca