# stacks advanced

Where Did It Break?

The inspector now files precise reports: the exact position (from 0) of the first troublemaker bracket. 📋

You get a string code of ()[]{}. Print the position of the first bracket that breaks the nesting — a closer with no partner or the wrong partner, or (if all closers behave) the first opener left unclosed. If nothing breaks, print balanced.

Example:

Input: code = "(]" Output: 1

( pushes, then ] arrives — the top of the stack is (, not the matching [, so position 1 is the first bad closer.

💡 need a hint?

stk-where-did-it-break.py🔒 given lines are locked — write your code in between
loading...