Mini Parser

|2021-5-25
AlphaBoom
AlphaBoom
Given a string s represents the serialization of a nested list, implement a parser to deserialize it and return the deserialized NestedInteger.
Each element is either an integer or a list whose elements may also be integers or other lists.
Example 1:
Example 2:
Constraints:
  • 1 <= s.length <= 5 * 104
  • s consists of digits, square brackets "[]", negative sign '-', and commas ','.
  • s is the serialization of valid NestedInteger.

  1. 每个NestedInteger对应一对"[]",每次读取到","即当前已经确定一个元素,最后这里会有个定义只要[]括起来的部分都算NestedInteger#list类型,就算里面只扩了一个数字
    Loading...