educative.io

Balanced bracket problem solution

Hello,

how do we satisfy the solution for more opening brackets in this code?

Type your question above this line.

Course: https://www.educative.io/collection/10370001/5473789393502208
Lesson: https://www.educative.io/collection/page/10370001/5473789393502208/5660463369027584

Hi @Habeebah_Ajao,

In that code, all the cases are already tackled where we can add as many opening brackets as we want because we are storing these brackets in a string type. Basically, the case is to check the balanced brackets, and the case we are using for that is as follows.

Case: The check variable will never be negative because it will imply that there are more closing brackets than opening brackets in the string.

And this case is enough to check the balanced brackets, and this case also satisfies the solution for more opening brackets.

I hope I have answered your query; please let me know if you still have any confusion.

Thank You :blush: