Cindy's Blog

アマゾンで働いているエンジニアの日常

2022-10-08から1日間の記事一覧

LeetCode 20. Valid Parentheses

Considering with following cases "]" "{[}]" class Solution { public boolean isValid(String s) { Stack<Character> stack = new Stack<>(); for (int i = 0; i < s.length(); i++){ char c = s.charAt(i); if (c == '(' || c == '[' || c == '{'){ stack.push(c); </character>…