Solved LeetCode program · 809 of 1,000
#1047 · Remove All Adjacent Duplicates In String
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.
Expected stdout
ca