Solved LeetCode program · 883 of 1,000
#1209 · Remove All Adjacent Duplicates in String II
Original English source
Keep a shared letters as an empty list of text. Keep a shared counts as an empty list of whole numbers. Keep a shared answer as empty text. Place "#" into letters. Place 0 into counts.
To extend from spot (a whole number). The piece is item spot of letters. The times is item spot of counts.
For every copy from 1 to times.
Place piece into answer.
The source is "deeedbbcccbdaa". The limit is 3. The last is the last position of source.
For every spot from 0 to last.
The piece is the slice of source from spot to spot plus 1. The size is the last position of letters. The top is item size of letters. The same is 0. If top matches piece, set same to 1. If same is 1, set item size of counts to item size of counts plus 1. If same is 0, Place piece into letters, Place 1 into counts. If same is 1 and item size of counts is limit, remove the last item from letters, remove the last item from counts.
The last is the last position of letters.
For every spot from 1 to last.
Extend from spot.
Show answer.
Expected stdout
aa