原题地址辅助栈代码: 1 bool isValid(string s) { 2 stack st; 3 4 for (auto c : s) { 5 if (st.empty()) 6 st.p...
分类:
其他好文 时间:
2015-02-02 21:21:59
阅读次数:
120
Given a string containing just the characters'('and')', find the length of the longest valid (well-formed) parentheses substring.For"(()", the longest...
分类:
其他好文 时间:
2015-02-02 14:03:33
阅读次数:
101
# -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com'32: Longest Valid Parentheseshttps://oj.leetcode.com/problems/longest-valid-parentheses/Gi...
分类:
编程语言 时间:
2015-02-01 01:52:20
阅读次数:
319
题目链接: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:
"((()))", "(()())", "(...
分类:
其他好文 时间:
2015-01-31 14:46:33
阅读次数:
141
题目链接: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 "...
分类:
其他好文 时间:
2015-01-30 22:40:16
阅读次数:
227
Given two integers representing the numerator and denominator of a fraction, return the fraction in string format.
If the fractional part is repeating, enclose the repeating part in parentheses....
分类:
其他好文 时间:
2015-01-30 15:55:05
阅读次数:
123
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:
"((()))", "(()())", "(())()", "()(())", "...
分类:
编程语言 时间:
2015-01-29 12:43:04
阅读次数:
157
Longest Valid Parentheses.
分类:
其他好文 时间:
2015-01-28 00:43:26
阅读次数:
202
# -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com'22: Generate Parentheseshttps://oj.leetcode.com/problems/generate-parentheses/Given n pair...
分类:
编程语言 时间:
2015-01-27 23:04:14
阅读次数:
162
原题链接:https://oj.leetcode.com/problemset/algorithms/
这里用递归的方法实现。递归函数签名为void generate(int left, int right, int n, string prev)
1. left,right分别为当前左右括号的个数,prev缓存之前的临时结果
2. left小于n的时候,可以一直加入左括号
3. ...
分类:
其他好文 时间:
2015-01-27 16:28:01
阅读次数:
120