Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
What observations can you make about the number of open brackets and close brackets for any prefix of a valid bracket sequence?
The number of open brackets must always be greater than or equal to the number of close brackets.
Could you use dynamic programming?