Description
You are given a string consisting of parentheses () and []. A string of this type is said to be correct:
(a)if it is the empty string(b)if A and B are correct, AB is correct,(c)...
分类:
其他好文 时间:
2014-05-22 09:53:27
阅读次数:
295
Generate Parentheses DFS...
分类:
其他好文 时间:
2014-05-21 16:40:29
阅读次数:
151
Valid Parentheses括号匹配问题...
分类:
其他好文 时间:
2014-05-21 16:02:30
阅读次数:
161
【题目】
Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.
For "(()", the longest valid parentheses substring is "()", which has length = 2.
Another example is ")()())", whe...
分类:
其他好文 时间:
2014-05-20 16:39:07
阅读次数:
280
【题目】
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.
【题意】
判断给定的字符串是否是合法的...
分类:
其他好文 时间:
2014-05-18 10:08:11
阅读次数:
327
【题目】
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:
"((()))", "(()())", "(())()", "()(())", "()()()"
【题意】
给定n对括号,输出所有可行的括号组合字符串。所谓合法,就是可以Valid Pare...
分类:
其他好文 时间:
2014-05-18 09:06:41
阅读次数:
266
【题目】
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.
【题意】
合并K个有序链表
【思路】
归并
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.
For ...
分类:
其他好文 时间:
2014-05-18 09:05:40
阅读次数:
255
题意:给定数字n,生成所有可能的n对括号的组合
思路:dfs暴力枚举
当左括号出现的次数 < n 的时候,可以选择放置新的左括号
当右括号出现的次数 < 左括号的次数的时候,可以选择放置新的右括号
递归函数:
void generateparenthesis(int n, int left, int right, vector& result)
表示将生成的所有可能的n对括号的组合放到result中,
其中,
s表示已生成的部分括号,
left表示当前的左括号数,
right表示当前的右括号...
分类:
其他好文 时间:
2014-05-15 13:21:12
阅读次数:
311
题目
Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.
For "(()", the longest valid parentheses substring is "()", ...
分类:
其他好文 时间:
2014-05-14 01:10:30
阅读次数:
318
题目如下:
Parentheses Balance
You are given a string consisting of parentheses () and []. A string of this type is said to be correct:
(a)
if it is the empty string
(b)
if A and B are ...
分类:
其他好文 时间:
2014-05-09 20:57:46
阅读次数:
316