Back to exercises

Valid Parentheses

Push opening brackets onto a stack and pop when you see a matching closer. Any mismatch or leftover opening bracket means the string is invalid.

Coding Exercises Easy O(n)

Valid Parentheses

Push opening brackets onto a stack and pop when you see a matching closer. Any mismatch or leftover opening bracket means the string is invalid.

Check whether brackets in a string are balanced and properly nested.