DIFF.BLOG
New
Following
Discover
Jobs
More
Suggest a blog
Upvotes plugin
Report bug
Contact
About
Sign up  
[Algorithm] Leetcode Valid Parentheses
1
·
Br
·
Nov. 29, 2021, midnight
Summary
Leetcode Valid Parentheses https://leetcode.com/problems/valid-parentheses/ Solution class Solution { public boolean isValid(String s) { Stack<Character> stack = new Stack<>(); for (char c : s.toCharArray()) { if (c == '(') { stack.add(')'); } else if (c == '[') { stack.add(']'); } else if (c == '{') { stack.add('}'); } else if (stack.isEmpty() || stack.pop() != c) { ...
Read full post on BryceYangS.github.io →
Submit
AUTHOR
RECENT POSTS FROM THE AUTHOR