mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-13 19:31:42 +08:00
add leetcode problem-cn part6
This commit is contained in:
37
算法题(国内版)/problem (Chinese)/迷你语法分析器 [mini-parser].html
Normal file
37
算法题(国内版)/problem (Chinese)/迷你语法分析器 [mini-parser].html
Normal file
@@ -0,0 +1,37 @@
|
||||
<p>给定一个字符串 s 表示一个整数嵌套列表,实现一个解析它的语法分析器并返回解析的结果 <code>NestedInteger</code> 。</p>
|
||||
|
||||
<p>列表中的每个元素只可能是整数或整数嵌套列表</p>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>示例 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>输入:</strong>s = "324",
|
||||
<strong>输出:</strong>324
|
||||
<strong>解释:</strong>你应该返回一个 NestedInteger 对象,其中只包含整数值 324。
|
||||
</pre>
|
||||
|
||||
<p><strong>示例 2:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>输入:</strong>s = "[123,[456,[789]]]",
|
||||
<strong>输出:</strong>[123,[456,[789]]]
|
||||
<strong>解释:</strong>返回一个 NestedInteger 对象包含一个有两个元素的嵌套列表:
|
||||
1. 一个 integer 包含值 123
|
||||
2. 一个包含两个元素的嵌套列表:
|
||||
i. 一个 integer 包含值 456
|
||||
ii. 一个包含一个元素的嵌套列表
|
||||
a. 一个 integer 包含值 789
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>提示:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>1 <= s.length <= 5 * 10<sup>4</sup></code></li>
|
||||
<li><code>s</code> 由数字、方括号 <code>"[]"</code>、负号 <code>'-'</code> 、逗号 <code>','</code>组成</li>
|
||||
<li>用例保证 <code>s</code> 是可解析的 <code>NestedInteger</code></li>
|
||||
<li>输入中的所有值的范围是 <code>[-10<sup>6</sup>, 10<sup>6</sup>]</code></li>
|
||||
</ul>
|
Reference in New Issue
Block a user