Approach hintTry it first, then revealHide
Keep two stacks of positions, one for lowercase and one for uppercase letters typed so far. A b or B pops the matching stack, and the surviving positions, printed in order, form the result.
Keep two stacks of positions, one for lowercase and one for uppercase letters typed so far. A b or B pops the matching stack, and the surviving positions, printed in order, form the result.