← Questions

Validate a bracket string after digit-driven deletions

0
GoogleCodingLast asked Aug 2025

A string mixes brackets and digits, for example (())2)1(). Each digit d requires removing exactly d of the brackets that come before it. Decide whether the deletions can be chosen so the remaining brackets are balanced. Agree on the exact rules with the interviewer, then work out a greedy or stack-based check.

Write and test your solution herePython in your browser, the question's tests level by level, saved for you.Sign in to start coding