Daily Archives: February 23, 2015


[leetcode] Generate Parentheses

Generate Parentheses Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For example, given n = 3, a solution set is: “((()))”, “(()())”, “(())()”, “()(())”, “()()()” tag: backtracking 7/10/2015 udpate DFS approach, add some restrictions to guarantee the validation of parentheses class Solution { […]


[leetcode] Valid Parentheses

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. tag: stack, string 5/10/2015 update a neater approach, with […]