Package g0301_0400.s0385_mini_parser
Class Solution
- java.lang.Object
-
- g0301_0400.s0385_mini_parser.Solution
-
public class Solution extends Object
385 - Mini Parser.Medium
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:
Input: s = “324”
Output: 324
Explanation: You should return a NestedInteger object which contains a single integer 324.
Example 2:
Input: s = “[123,[456,[789]]]”
Output: [123,[456,[789]]]
Explanation: Return a NestedInteger object containing a nested list with 2 elements:
-
An integer containing value 123.
-
A nested list containing two elements:
i. An integer containing value 456.
ii. A nested list with one element:
a. An integer containing value 789
Constraints:
1 <= s.length <= 5 * 104
s
consists of digits, square brackets"[]"
, negative sign'-'
, and commas','
.s
is the serialization of validNestedInteger
.- All the values in the input are in the range
[-106, 106]
.
-
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description NestedInteger
deserialize(String s)
-
-
-
Method Detail
-
deserialize
public NestedInteger deserialize(String s)
-
-