题目: Please give a function to check matching pairs of braces, parenthese and brackets
function isMatchingPair(str) {
// your code here
}
isMatchingPair('(str[x)xx]') // return false
isMatchingPair('({[str]})') // return true
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
栈结构括号匹配。
维护一个栈结构,遍历字符串,与当前栈顶比较,若栈顶为左,遍历者为右,并且同一型号括号,则消去。非括号略过。
遍历完后若栈长度为0则说明匹配,否则不匹配。
哇 能问下是哪里的面试题吗 感觉还是不容易的