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 ...
分类:
其他好文 时间:
2014-09-22 03:21:11
阅读次数:
264
思路:可用于卡特兰数一类题目。
思路: 栈。对 S 的每个字符检查栈尾,若成对,则出栈,否则,入栈。
分类:
其他好文 时间:
2014-09-21 17:11:40
阅读次数:
218
Longest Valid Parentheses
Total Accepted: 14818 Total
Submissions: 75749My Submissions
Given a string containing just the characters '(' and ')',
find the length of the longest valid (w...
分类:
其他好文 时间:
2014-09-09 13:18:18
阅读次数:
166
Valid Parentheses
Total Accepted: 17916 Total
Submissions: 63131My Submissions
Given a string containing just the characters '(', ')', '{', '}', '[' and ']',
determine if the input stri...
分类:
其他好文 时间:
2014-09-07 16:03:05
阅读次数:
168
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:"((...
分类:
其他好文 时间:
2014-09-06 16:05:23
阅读次数:
182
说说:
题意就是由字符串中的[]()匹不匹配的问题。解法很简单,搞个栈就搞定了。但是题目中有一个陷阱,那就是字符串为空也是合理的。所以在读取字符串的时候最好使用gets,因为scanf会自动将换行给忽略掉的。
源代码:
#include
#include
#define MAXN 128+5
int main(){
char stack[MAXN],c,s[MAXN];
...
分类:
其他好文 时间:
2014-09-05 19:56:31
阅读次数:
163
Givennpairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, givenn= 3, a solution set is:"((()))...
分类:
其他好文 时间:
2014-09-04 22:17:00
阅读次数:
185
Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the lon...
分类:
其他好文 时间:
2014-09-03 22:30:07
阅读次数:
211
Given a string containing just the characters'('and')', find the length of the longest valid (well-formed) parentheses substring.For"(()", the longest...
分类:
其他好文 时间:
2014-09-03 10:59:16
阅读次数:
183
问题描述
Given a string containing just the characters '(', ')', '{', '}', '[' and ']',
determine if the input string is valid.
The brackets must close in the correct order, "()" and "()[]{}" ...
分类:
其他好文 时间:
2014-09-02 19:54:15
阅读次数:
150