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.
package pack;
import java.util.HashMap;
import java.util.Stack;
class Solution {
public boolean isValid(String s) {
HashMap<Character, Character

该博客讨论了如何确定给定字符串中的括号是否有效,即括号必须按照正确的顺序关闭。例如,'()' 和 '()[]{}' 是有效的,而 '(]' 和 '([)]' 不是。
订阅专栏 解锁全文
501

被折叠的 条评论
为什么被折叠?



