mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-10-22 13:36:46 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>给定一个只包括 <code>'('</code>,<code>')'</code>,<code>'{'</code>,<code>'}'</code>,<code>'['</code>,<code>']'</code> 的字符串 <code>s</code> ,判断字符串是否有效。</p>\n\n<p>有效字符串需满足:</p>\n\n<ol>\n\t<li>左括号必须用相同类型的右括号闭合。</li>\n\t<li>左括号必须以正确的顺序闭合。</li>\n</ol>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre>\n<strong>输入:</strong>s = \"()\"\n<strong>输出:</strong>true\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre>\n<strong>输入:</strong>s = \"()[]{}\"\n<strong>输出:</strong>true\n</pre>\n\n<p><strong>示例 3:</strong></p>\n\n<pre>\n<strong>输入:</strong>s = \"(]\"\n<strong>输出:</strong>false\n</pre>\n\n<p><strong>示例 4:</strong></p>\n\n<pre>\n<strong>输入:</strong>s = \"([)]\"\n<strong>输出:</strong>false\n</pre>\n\n<p><strong>示例 5:</strong></p>\n\n<pre>\n<strong>输入:</strong>s = \"{[]}\"\n<strong>输出:</strong>true</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 <= s.length <= 10<sup>4</sup></code></li>\n\t<li><code>s</code> 仅由括号 <code>'()[]{}'</code> 组成</li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Easy",
|
||||
"likes": 3121,
|
||||
"likes": 3127,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[{\"title\": \"Generate Parentheses\", \"titleSlug\": \"generate-parentheses\", \"difficulty\": \"Medium\", \"translatedTitle\": \"\\u62ec\\u53f7\\u751f\\u6210\"}, {\"title\": \"Longest Valid Parentheses\", \"titleSlug\": \"longest-valid-parentheses\", \"difficulty\": \"Hard\", \"translatedTitle\": \"\\u6700\\u957f\\u6709\\u6548\\u62ec\\u53f7\"}, {\"title\": \"Remove Invalid Parentheses\", \"titleSlug\": \"remove-invalid-parentheses\", \"difficulty\": \"Hard\", \"translatedTitle\": \"\\u5220\\u9664\\u65e0\\u6548\\u7684\\u62ec\\u53f7\"}, {\"title\": \"Check If Word Is Valid After Substitutions\", \"titleSlug\": \"check-if-word-is-valid-after-substitutions\", \"difficulty\": \"Medium\", \"translatedTitle\": \"\\u68c0\\u67e5\\u66ff\\u6362\\u540e\\u7684\\u8bcd\\u662f\\u5426\\u6709\\u6548\"}]",
|
||||
@@ -143,7 +143,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"1M\", \"totalSubmission\": \"2.3M\", \"totalAcceptedRaw\": 1004287, \"totalSubmissionRaw\": 2255523, \"acRate\": \"44.5%\"}",
|
||||
"stats": "{\"totalAccepted\": \"1M\", \"totalSubmission\": \"2.3M\", \"totalAcceptedRaw\": 1007900, \"totalSubmissionRaw\": 2263348, \"acRate\": \"44.5%\"}",
|
||||
"hints": [
|
||||
"An interesting property about a valid parenthesis expression is that a sub-expression of a valid expression should also be a valid expression. (Not every sub-expression) e.g.\r\n\r\n<pre>\r\n{ { } [ ] [ [ [ ] ] ] } is VALID expression\r\n [ [ [ ] ] ] is VALID sub-expression\r\n { } [ ] is VALID sub-expression\r\n</pre>\r\n\r\nCan we exploit this recursive structure somehow?",
|
||||
"What if whenever we encounter a matching pair of parenthesis in the expression, we simply remove it from the expression? This would keep on shortening the expression. e.g.\r\n\r\n<pre>\r\n{ { ( { } ) } }\r\n |_|\r\n\r\n{ { ( ) } }\r\n |______|\r\n\r\n{ { } }\r\n |__________|\r\n\r\n{ }\r\n|________________|\r\n\r\nVALID EXPRESSION!\r\n</pre>",
|
||||
|
Reference in New Issue
Block a user