385. Mini Parser Medium
1/**
2 * [385] Mini Parser
3 *
4 * Given a string s represents the serialization of a nested list, implement a parser to deserialize it and return the deserialized NestedInteger.
5 * Each element is either an integer or a list whose elements may also be integers or other lists.
6 *
7 * Example 1:
8 *
9 * Input: s = "324"
10 * Output: 324
11 * Explanation: You should return a NestedInteger object which contains a single integer 324.
12 *
13 * Example 2:
14 *
15 * Input: s = "[123,[456,[789]]]"
16 * Output: [123,[456,[789]]]
17 * Explanation: Return a NestedInteger object containing a nested list with 2 elements:
18 * 1. An integer containing value 123.
19 * 2. A nested list containing two elements:
20 * i. An integer containing value 456.
21 * ii. A nested list with one element:
22 * a. An integer containing value 789
23 *
24 *
25 * Constraints:
26 *
27 * 1 <= s.length <= 5 * 10^4
28 * s consists of digits, square brackets "[]", negative sign '-', and commas ','.
29 * s is the serialization of valid NestedInteger.
30 * All the values in the input are in the range [-10^6, 10^6].
31 *
32 */
33pub struct Solution {}
34
35// problem: https://leetcode.com/problems/mini-parser/
36// discuss: https://leetcode.com/problems/mini-parser/discuss/?currentPage=1&orderBy=most_votes&query=
37
38// submission codes start here
39
40// #[derive(Debug, PartialEq, Eq)]
41// pub enum NestedInteger {
42// Int(i32),
43// List(Vec<NestedInteger>)
44// }
45impl Solution {
46 pub fn deserialize(s: String) -> NestedInteger {
47
48 }
49}
50
51// submission codes end
52
53#[cfg(test)]
54mod tests {
55 use super::*;
56
57 #[test]
58 fn test_385() {
59 }
60}
61
Back
© 2025 bowen.ge All Rights Reserved.