Menu Sidebar
Menu

stack

[LintCode] Valid Parentheses

public boolean isValidParentheses(String s) { // Write your code here Stack<Character> st = new Stack<Character>(); if(s.length() == 0 || s == null) return false; for(int i = 0 ; i < s.length(); i++) { if(s.charAt(i) == ‘(‘ || s.charAt(i) == ‘[‘ || s.charAt(i) == ‘{‘) st.push(s.charAt(i)); else{ if(st.isEmpty()) return false; if(s.charAt(i) == ‘)’ && st.peek() […]

书脊

这青苔碧瓦堆, 俺曾睡风流觉, 将五十年兴亡看饱.

November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930