102. validate string of parentheses
Share
easy - accepted / - tried
Given a string containing only following characters:
- parentheses :
(
or)
- brackets:
[
or]
- braces:
{
or}
write a function to determine if they are valid.
By 'valid', it means all should be rightly paired, and with the valid order.
validate('{}[]()') // truevalidate('{[()]}') // truevalidate('{[}]') // false, they are not in the right ordervalidate('{}}') // false, last `}` is not paired with `{`
Follow-up
What is time & space complexity of your approach ? Can you do it better?