20. Valid Parentheses

来源:互联网 发布:薛之谦男装淘宝店网址 编辑:程序博客网 时间:2024/06/08 04:58

题目摘要
给一个只含有”(“, “)”, “[“, “]”, “{“, “}”的字符串,判断括号合并顺序是否正确

解法
Stack

注意
* 奇数个字符肯定错误

原题
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.

The brackets must close in the correct order, "()" and "()[]{}" are all valid but "(]" and "([)]" are not.

Subscribe to see which companies asked this question

0 0
原创粉丝点击