ShipBob interview question

coding problem on balance parenthesis along with a variation.