# stacks advanced

Bubble Pop Chain

Two identical bubbles touching? POP — they both vanish, and the bubbles around them slide together, maybe triggering ANOTHER pop… 🫧

You get a string bubbles. Remove adjacent identical pairs over and over until none remain. Print what survives, or all popped. One stack pass handles every chain reaction!

Example:

Input: bubbles = "abbaca" Output: ca

Push a, push b; the second b matches the top and pops both bs; the new top a then matches the next a and pops both — leaving just c, a on the stack.

💡 need a hint?

stk-bubble-pop-chain.py🔒 given lines are locked — write your code in between
loading...