Valid Parentheses
MediumGiven a single string of opening and closing brackets:
()
, []
, {}
, write a function that returns True
if the open brackets are closed properly, and False
if it is not.For example, given the following string:
[{()}]
Your function should return
True
since all brackets are closed properly.However, the input string:
({()}]
is invalid since the last character doesn't close its respective bracket.
Try it first
Solution
5 Essential Stacks & Queues Coding Interview Problems
Master Stacks & Queues by trying the coding challenges below.
- 1.Implement StackEasy
- 2.Implement QueueEasy
- 3.Max StackMedium
- 4.Valid ParenthesesMedium
- 5.Simplify PathMedium