题目:Remove the minimum number of invalid parentheses in order to make the input string valid. Return all possible results.Note: The input string may co...
分类:
其他好文 时间:
2015-12-16 00:13:11
阅读次数:
775
题目连接https://leetcode.com/problems/valid-parentheses/Valid ParenthesesDescriptionGiven a string containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[’ ...
分类:
其他好文 时间:
2015-12-11 22:11:43
阅读次数:
169
Remove the minimum number of invalid parentheses in order to make the input string valid. Return all possible results.Note: The input string may conta...
分类:
其他好文 时间:
2015-12-06 22:25:48
阅读次数:
156
可以借助 stack 一次遍历就将全部有效括号替换为 '.'。 第一步:一次遍历,stack 只存放 '(' 的下标。 当找到一个 '(',则压进 stack ; 当找到一个 ')',则把 stack.top 对于的字符替换为 '.',并弹出 stack.pop()。耗时O(n...
分类:
其他好文 时间:
2015-12-06 17:47:28
阅读次数:
139
题目连接https://leetcode.com/problems/remove-invalid-parentheses/Remove Invalid ParenthesesDescriptionRemove the minimum number of invalid parentheses in ...
分类:
其他好文 时间:
2015-12-01 21:16:20
阅读次数:
236
题目:Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators....
分类:
其他好文 时间:
2015-11-30 08:32:08
阅读次数:
334
翻译给定一个仅仅包含“(”或“)”的字符串,找到其中最长有效括号子集的长度。对于“(()”,它的最长有效括号子集是“()”,长度为2。另一个例子“)()())”,它的最长有效括号子集是“()()”,其长度是4。原文Given a string containing just the characters '(' and ')',
find the length of the longest val...
分类:
其他好文 时间:
2015-11-26 19:15:52
阅读次数:
148
# 解题思路: # 创建一个字典映射关系 dicts# 使用一个栈stk 遍历字符串s 得到一个新的字符串curItem 如果lastItem在dicts中的value和它相等 不做任何操作# 如果不等 入栈 有lastItem的 先append lastItem 然后是curItem ## 最后判...
分类:
编程语言 时间:
2015-11-22 00:17:55
阅读次数:
174
题目描述:(链接)Given a string containing just the characters'('and')', find the length of the longest valid (well-formed) parentheses substring.For"(()", th...
分类:
其他好文 时间:
2015-11-17 18:47:05
阅读次数:
142
原题链接在这里:https://leetcode.com/problems/remove-invalid-parentheses/题目要求减少最小个数的非法括号,要求最小,就想到BFS.Queue 里加入 原来的string s, 循环中从queue中poll出来一个string. 每次减掉一个括号...
分类:
其他好文 时间:
2015-11-13 10:29:00
阅读次数:
226