码迷,mamicode.com
首页 >  
搜索关键字:parentheses    ( 825个结果
刷题78. Subsets
一、题目说明 题目78. Subsets,给一列整数,求所有可能的子集。题目难度是Medium! 二、我的解答 这个题目,前面做过一个类似的,相当于求闭包: 刷题22. Generate Parentheses 算了,用最简单的回溯法吧: 性能如下: 三、优化措施 当然,用 刷题22. Genera ...
分类:其他好文   时间:2020-02-24 09:32:10    阅读次数:95
20. Valid Parentheses
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Op ...
分类:其他好文   时间:2020-02-13 21:05:49    阅读次数:52
1249. Minimum Remove to Make Valid Parentheses
Given a string s of '(' , ')' and lowercase English characters. Your task is to remove the minimum number of parentheses ( '(' or ')', in any position ...
分类:其他好文   时间:2020-02-06 14:49:15    阅读次数:69
刷题32. Longest Valid Parentheses
一、题目说明 题目是32. Longest Valid Parentheses,求最大匹配的括号长度。题目的难度是Hard 二、我的做题方法 简单理解了一下,用栈就可以实现。实际上是我考虑简单了,经过5次提交终于正确了。 性能如下: 代码如下: 三、优化措施 题解给了4种方法,这4种方法都比较好理解 ...
分类:其他好文   时间:2020-02-06 10:20:13    阅读次数:50
刷题20. Valid Parentheses
一、题目说明 这个题目是20. Valid Parentheses,简单来说就是括号匹配。在学数据结构的时候,用栈可以解决。题目难度是Medium。 二、我的解答 栈涉及的内容不多,push、pop、top,。 我总共提交了3次: 第1次:Runtime Error,错误原因在于pop的时候,未判断 ...
分类:其他好文   时间:2020-02-01 10:59:40    阅读次数:75
leetcode22 括号生成
题目 :https://leetcode cn.com/problems/generate parentheses/ 给出 n 代表生成括号的对数,请你写出一个函数,使其能够生成所有可能的并且有效的括号组合。 样例输入与输出 : n = 3 输出: [ "((()))", "(()())", "(( ...
分类:其他好文   时间:2020-01-30 19:30:17    阅读次数:75
20. Valid Parentheses做题报告
题目链接: Valid Parentheses 题目大意: 判断字符串s的字符是否满足符号匹配 做题报告: (1)该题涉及的算法与数据结构 栈,哈希表 (2)自己的解答思路+代码+分析时间和空间复杂度 思路: 栈先入后出特点,若遇到左括号入栈,遇到右括号时将对应栈顶左括号出栈,则遍历完所有括号后 s ...
分类:其他好文   时间:2020-01-21 00:23:49    阅读次数:87
20. 有效的括号(栈的使用)
题目描述:括号(小括号、中括号、大括号)的匹配 传送门:https://leetcode-cn.com/problems/valid-parentheses/ 解法:《数据结构》中作为例子引出栈的概念。用一个栈维护,从左到右扫描目标字符串,如果括号匹配,即满足三种情况: ①、s[i] == ')' ...
分类:其他好文   时间:2020-01-13 20:19:49    阅读次数:95
leetcode 1021 Remove Outermost Parentheses
A valid parentheses string is either empty (""), "(" + A + ")", or A + B, where A and B are valid parentheses strings, and +represents string concaten ...
分类:其他好文   时间:2019-12-31 14:44:42    阅读次数:90
LeetCode 1021. Remove Outermost Parentheses
原题链接在这里:https://leetcode.com/problems/remove-outermost-parentheses/ 题目: A valid parentheses string is either empty (""), "(" + A + ")", or A + B, wher ...
分类:其他好文   时间:2019-12-22 10:58:31    阅读次数:90
825条   上一页 1 2 3 4 5 6 ... 83 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!