question_slug
stringlengths
3
77
title
stringlengths
1
183
slug
stringlengths
12
45
summary
stringlengths
1
160
author
stringlengths
2
30
certification
stringclasses
2 values
created_at
stringdate
2013-10-25 17:32:12
2025-04-12 09:38:24
updated_at
stringdate
2013-10-25 17:32:12
2025-04-12 09:38:24
hit_count
int64
0
10.6M
has_video
bool
2 classes
content
stringlengths
4
576k
upvotes
int64
0
11.5k
downvotes
int64
0
358
tags
stringlengths
2
193
comments
int64
0
2.56k
groups-of-special-equivalent-strings
C++ 100%
c-100-by-eridanoy-jfqp
\nclass Solution {\npublic:\n int numSpecialEquivGroups(const vector<string>& A) {\n unordered_set<string> us;\n for(const auto& s:A) {\n
eridanoy
NORMAL
2020-11-25T23:09:34.748514+00:00
2020-11-25T23:09:34.748547+00:00
163
false
```\nclass Solution {\npublic:\n int numSpecialEquivGroups(const vector<string>& A) {\n unordered_set<string> us;\n for(const auto& s:A) {\n string s1,s2;\n for(int i=0; i<s.size(); ++++i) s1+=s[i];\n sort(s1.begin(),s1.end());\n for(int i=1; i<s.size(); ++++...
1
0
['C']
0
groups-of-special-equivalent-strings
Easy Clean JavaScript
easy-clean-javascript-by-fl4sk-bxws
\nconst numSpecialEquivGroups = A => {\n \n const sortChars = str => {\n const odd = [...str].filter((_,i) => i%2);\n const even = [...str].filter((_,i
fl4sk
NORMAL
2020-11-25T03:16:48.973220+00:00
2020-11-25T03:16:48.973265+00:00
66
false
```\nconst numSpecialEquivGroups = A => {\n \n const sortChars = str => {\n const odd = [...str].filter((_,i) => i%2);\n const even = [...str].filter((_,i) => !(i%2));\n return `${odd.sort().join(\'\')}${even.sort().join(\'\')}`\n };\n \n const set = new Set();\n A.forEach(str => set.add(sortChars(str))...
1
0
[]
0
groups-of-special-equivalent-strings
Java 1 Line
java-1-line-by-wit-nq2b
\npublic int numSpecialEquivGroups(String[] array) {\n\treturn Arrays.stream(array).map(s -> IntStream.range(0, s.length()).boxed().collect(Collectors.toMap(i -
wit
NORMAL
2020-11-24T03:21:47.163526+00:00
2020-11-24T03:21:47.163575+00:00
226
false
```\npublic int numSpecialEquivGroups(String[] array) {\n\treturn Arrays.stream(array).map(s -> IntStream.range(0, s.length()).boxed().collect(Collectors.toMap(i -> s.charAt(i) + 26 * (i & 1), i -> 1, Integer::sum)).entrySet().stream().sorted(Map.Entry.comparingByKey()).map(Object::toString).collect(Collectors.joining(...
1
0
[]
0
groups-of-special-equivalent-strings
Easy Python 3
easy-python-3-by-svr300-s3zn
\tclass Solution:\n def numSpecialEquivGroups(self, A: List[str]) -> int:\n ls=[]\n for i in A:\n odd=i[0::2]\n even=i[1:
svr300
NORMAL
2020-10-30T02:46:17.393262+00:00
2020-10-30T02:46:17.393312+00:00
89
false
\tclass Solution:\n def numSpecialEquivGroups(self, A: List[str]) -> int:\n ls=[]\n for i in A:\n odd=i[0::2]\n even=i[1::2]\n ls.append(tuple(sorted(odd)+sorted(even)))\n\n return len(set(ls))
1
0
[]
0
groups-of-special-equivalent-strings
easiest C++
easiest-c-by-adiabatic123-90di
\nclass Solution {\npublic:\n int numSpecialEquivGroups(vector<string>& a) {\n unordered_set<string>s1;\n for(int i=0;i<a.size();i++){\n
adiabatic123
NORMAL
2020-10-21T12:07:24.168453+00:00
2020-10-21T12:07:24.168480+00:00
84
false
```\nclass Solution {\npublic:\n int numSpecialEquivGroups(vector<string>& a) {\n unordered_set<string>s1;\n for(int i=0;i<a.size();i++){\n string s=a[i];\n string odd="",even="";\n for(int i=0;i<s.length();i++){\n if(i%2==0)\n even+=s[...
1
0
[]
0
groups-of-special-equivalent-strings
Well, prime numbers helped
well-prime-numbers-helped-by-mesurajpand-rsan
\npublic int numSpecialEquivGroups(String[] A) {\n int len = A.length;\n int[] firstTwentySixPrimes = new int[]{2, 3, 5, 7, 11, 13, 17, 19, 23, 29
mesurajpandey
NORMAL
2020-09-28T01:38:30.999923+00:00
2020-09-28T01:38:30.999967+00:00
65
false
```\npublic int numSpecialEquivGroups(String[] A) {\n int len = A.length;\n int[] firstTwentySixPrimes = new int[]{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101};\n Set<String> result = new HashSet<>();\n for(int i=0;i<len;i++) {\n ...
1
0
[]
0
groups-of-special-equivalent-strings
JAVA O(26*N)
java-o26n-by-gobblin_insights-qoma
\nclass Solution {\n private String evenOdd(String str){\n int n = str.length();\n int [] even = new int[26];\n int [] odd = new int[26]
gobblin_insights
NORMAL
2020-08-27T16:33:08.177137+00:00
2020-08-27T16:33:08.177192+00:00
201
false
```\nclass Solution {\n private String evenOdd(String str){\n int n = str.length();\n int [] even = new int[26];\n int [] odd = new int[26];\n for(int i=0;i<n;i++){\n char c = str.charAt(i);\n if(i%2==0){\n even[c-\'a\']++;\n }else{\n ...
1
0
[]
0
groups-of-special-equivalent-strings
C++, easy-understand, set, dict
c-easy-understand-set-dict-by-zxspring21-9ho5
\nclass Solution {\npublic:\n int numSpecialEquivGroups(vector<string>& A) {\n set<string> s;\n for(int i=0; i<A.size(); ++i){\n int
zxspring21
NORMAL
2020-08-26T13:07:46.242210+00:00
2020-08-26T13:07:46.242243+00:00
205
false
```\nclass Solution {\npublic:\n int numSpecialEquivGroups(vector<string>& A) {\n set<string> s;\n for(int i=0; i<A.size(); ++i){\n int even[26]={0}, odd[26]={0};\n string index;\n for(int j=0; j< A[i].size(); ++j){\n if(j%2) even[A[i][j]-\'a\']++;\n ...
1
1
['C']
0
groups-of-special-equivalent-strings
Python One Liner
python-one-liner-by-frank_paul-lw3q
\nclass Solution: \n def numSpecialEquivGroups(self, A: List[str]) -> int:\n return len(set(\'\'.join(sorted(stri[i] for i in range(len(stri))
frank_paul
NORMAL
2020-07-24T05:02:02.163366+00:00
2020-07-24T05:04:45.387840+00:00
283
false
```\nclass Solution: \n def numSpecialEquivGroups(self, A: List[str]) -> int:\n return len(set(\'\'.join(sorted(stri[i] for i in range(len(stri)) if i%2==0)) + \'\'.join(sorted(stri[i] for i in range(len(stri)) if i%2!=0)) for stri in A))\n```
1
6
['Python', 'Python3']
0
groups-of-special-equivalent-strings
easy understanding c++ using set and count array
easy-understanding-c-using-set-and-count-5h5m
\nclass Solution {\npublic:\n int numSpecialEquivGroups(vector<string>& A) {\n unordered_set<string>s;\n for(int i=0;i<A.size();i++)\n
imsoundharvidhu
NORMAL
2020-06-07T07:49:02.217793+00:00
2020-06-07T07:49:02.217830+00:00
178
false
```\nclass Solution {\npublic:\n int numSpecialEquivGroups(vector<string>& A) {\n unordered_set<string>s;\n for(int i=0;i<A.size();i++)\n s.insert(createhash(A[i]));\n return s.size();\n }\n static string createhash(string a)\n {\n string res="";\n vector<int>ev...
1
0
['C', 'Ordered Set', 'C++']
0
groups-of-special-equivalent-strings
Python soln
python-soln-by-vharshal1994-mk3j
\nclass Solution(object):\n def numSpecialEquivGroups(self, A):\n """\n :type A: List[str]\n :rtype: int\n """\n #https://
vharshal1994
NORMAL
2020-05-15T14:17:53.857357+00:00
2020-05-15T14:17:53.857411+00:00
137
false
```\nclass Solution(object):\n def numSpecialEquivGroups(self, A):\n """\n :type A: List[str]\n :rtype: int\n """\n #https://leetcode.com/problems/groups-of-special-equivalent-strings/discuss/358795/python3-detail-explanation-of-special-equivalent\n \n if len(A) == 1:...
1
0
[]
1
groups-of-special-equivalent-strings
Groups of Special-Equivalent Strings
groups-of-special-equivalent-strings-by-lcthn
```\n // Runtime: 6 ms, faster than 82.18% of Java online submissions for Groups of Special-Equivalent Strings.\n // Memory Usage: 39.3 MB, less than 7.69
tenzindadhul
NORMAL
2020-05-15T08:55:22.951990+00:00
2020-05-15T08:55:22.952026+00:00
55
false
```\n // Runtime: 6 ms, faster than 82.18% of Java online submissions for Groups of Special-Equivalent Strings.\n // Memory Usage: 39.3 MB, less than 7.69% of Java online submissions for Groups of Special-Equivalent Strings.\n public int numSpecialEquivGroups(String[] A) {\n Set<String> uniqueSet = new ...
1
0
[]
0
groups-of-special-equivalent-strings
Python3 Solution - Sort
python3-solution-sort-by-ma_e-bp4j
class Solution:\n def numSpecialEquivGroups(self, A: List[str]) -> int:\n\n # sort string by index \n def F(s):\n odd, even = "", "
ma_e
NORMAL
2020-04-07T21:36:07.155472+00:00
2020-04-07T21:36:07.155507+00:00
84
false
class Solution:\n def numSpecialEquivGroups(self, A: List[str]) -> int:\n\n # sort string by index \n def F(s):\n odd, even = "", ""\n for i in range(len(s)):\n if i % 2 == 0: even += s[i]\n else: odd += s[i]\n return "".join(sorted(even) ...
1
0
[]
0
groups-of-special-equivalent-strings
[Swift] Character Counting
swift-character-counting-by-alptekin35-bngz
\nclass Solution {\n func numSpecialEquivGroups(_ A: [String]) -> Int {\n var set:Set<String> = Set()\n for item in A{\n let chars =
alptekin35
NORMAL
2020-03-16T04:22:28.401645+00:00
2020-03-16T04:22:28.401677+00:00
54
false
```\nclass Solution {\n func numSpecialEquivGroups(_ A: [String]) -> Int {\n var set:Set<String> = Set()\n for item in A{\n let chars = Array(item)\n var arr:[Character] = Array(repeating: "0", count: 52)\n for i in 0..<chars.count{\n if i % 2 == 0{\n ...
1
0
['Swift']
0
groups-of-special-equivalent-strings
python3 simple solution
python3-simple-solution-by-boekveld-gtrw
If two strings are special-equivalent,\nthey share the following tuple:\n\n(sorted string made of characters of the original strings of even indices,\nsorted st
boekveld
NORMAL
2020-01-21T13:12:26.881946+00:00
2020-01-21T13:13:54.579956+00:00
131
false
If two strings are special-equivalent,\nthey share the following tuple:\n\n(sorted string made of characters of the original strings of even indices,\nsorted str. made of chars. of the orig. strs. of odd indices)\n\nTherefore, if we make such tuples from each string and put into a set,\nthe length of the set is the ans...
1
0
[]
0
groups-of-special-equivalent-strings
Java Solution
java-solution-by-prjadhav-amag
```\nclass Solution {\n public int numSpecialEquivGroups(String[] A) {\n Set set=new HashSet();\n for(String s:A){\n int[] evenChars
prjadhav
NORMAL
2019-12-30T23:23:31.472943+00:00
2019-12-30T23:23:31.472976+00:00
157
false
```\nclass Solution {\n public int numSpecialEquivGroups(String[] A) {\n Set<String> set=new HashSet();\n for(String s:A){\n int[] evenChars=new int[26];\n int[] oddChars=new int[26];\n for(int i=0;i<s.length();i++){\n if(i%2==0){\n eve...
1
0
[]
0
groups-of-special-equivalent-strings
C# Solution with LINQ
c-solution-with-linq-by-mhorskaya-dqpx
\npublic int NumSpecialEquivGroups(string[] A) {\n\treturn A.Select(Order).Distinct().Count();\n\n\tstring Order(string s) {\n\t\tvar chars = s.Select((c, i) =>
mhorskaya
NORMAL
2019-12-23T11:51:31.678590+00:00
2019-12-23T11:51:31.678622+00:00
63
false
```\npublic int NumSpecialEquivGroups(string[] A) {\n\treturn A.Select(Order).Distinct().Count();\n\n\tstring Order(string s) {\n\t\tvar chars = s.Select((c, i) => (i, c)).ToArray();\n\t\tvar evens = chars.Where(t => t.i % 2 == 0).Select(t => t.c).OrderBy(c => c);\n\t\tvar odds = chars.Where(t => t.i % 2 == 1).Select(t...
1
0
[]
0
groups-of-special-equivalent-strings
Count the characters at even and odd positions
count-the-characters-at-even-and-odd-pos-oazn
csharp\npublic int NumSpecialEquivGroups(string[] A)\n{\n\tHashSet<string> groupCount = new HashSet<string>();\n\n\tforeach (var a in A)\n\t{\n\t\tint[] frequen
christris
NORMAL
2019-11-20T02:46:19.716393+00:00
2019-11-20T02:51:22.687782+00:00
112
false
```csharp\npublic int NumSpecialEquivGroups(string[] A)\n{\n\tHashSet<string> groupCount = new HashSet<string>();\n\n\tforeach (var a in A)\n\t{\n\t\tint[] frequency = new int[26 * 2];\n\t\tfor (int i = 0; i < a.Length; i++)\n\t\t{\n\t\t\tif (i % 2 == 0)\n\t\t\t{\n\t\t\t\tfrequency[a[i] - \'a\']++;\n\t\t\t}\n\t\t\telse...
1
0
[]
0
groups-of-special-equivalent-strings
Brute Force And Optimized Solution in Cpp!
brute-force-and-optimized-solution-in-cp-vb13
Here we have to sort substrings so nlogn!\n\nclass Solution {\npublic:\n int numSpecialEquivGroups(vector<string>& a) {\n map<string,vector<string>>m;
sanjaygarg
NORMAL
2019-10-22T11:27:23.642769+00:00
2019-10-22T11:27:23.642807+00:00
71
false
Here we have to sort substrings so nlogn!\n```\nclass Solution {\npublic:\n int numSpecialEquivGroups(vector<string>& a) {\n map<string,vector<string>>m;\n int count=0;\n int n=a.size();\n for(int i=0;i<n;i++)\n {\n string odd="";\n string even="";\n ...
1
0
[]
0
groups-of-special-equivalent-strings
Go golang clean solution
go-golang-clean-solution-by-leaf_peng-dsuz
Runtime: 4 ms, faster than 71.43% of Go online submissions for Groups of Special-Equivalent Strings.\nMemory Usage: 4.3 MB, less than 100.00% of Go online submi
leaf_peng
NORMAL
2019-08-08T01:07:10.763715+00:00
2019-08-08T01:07:10.763752+00:00
79
false
Runtime: 4 ms, faster than 71.43% of Go online submissions for Groups of Special-Equivalent Strings.\nMemory Usage: 4.3 MB, less than 100.00% of Go online submissions for Groups of Special-Equivalent Strings.\n\n```go\nfunc numSpecialEquivGroups(A []string) int {\n\n\ttmp := make(map[string]int)\n \n\tfor _, v := ra...
1
0
[]
0
groups-of-special-equivalent-strings
Python one liner
python-one-liner-by-josephzheng-f9r4
\nclass Solution:\n def numSpecialEquivGroups(self, A: List[str]) -> int:\n return len(set(\'\'.join(sorted(w[::2]) + sorted(w[1::2])) for w in A))\n
josephzheng
NORMAL
2019-07-29T17:19:08.086183+00:00
2019-07-29T17:19:08.086215+00:00
118
false
```\nclass Solution:\n def numSpecialEquivGroups(self, A: List[str]) -> int:\n return len(set(\'\'.join(sorted(w[::2]) + sorted(w[1::2])) for w in A))\n```
1
0
[]
0
groups-of-special-equivalent-strings
JS simple solution with explanation
js-simple-solution-with-explanation-by-y-43pp
We can calculate the signature of each word in the word array, and see how many distinct word signature there are, which would be the result. The signature is d
yushi_lu
NORMAL
2019-07-17T03:08:02.937824+00:00
2019-07-17T03:08:02.937871+00:00
225
false
We can calculate the *signature* of each word in the word array, and see how many distinct *word signature* there are, which would be the result. The *signature* is defined as:\n* extract all even-indexed chars and sort them\n* extract all odd-indexed chars and sort them\n* combine the above two\n\nTake the word "abccb...
1
0
['JavaScript']
0
groups-of-special-equivalent-strings
Python Sol for Starters - EXTREMELY EASY
python-sol-for-starters-extremely-easy-b-vecr
python\nclass Solution:\n def numSpecialEquivGroups(self, A: List[str]) -> int:\n length = len(A)\n res = set()\n for item in A:\n
deadline_killer_mzq
NORMAL
2019-06-14T15:20:05.589896+00:00
2019-06-14T15:20:05.589936+00:00
171
false
```python\nclass Solution:\n def numSpecialEquivGroups(self, A: List[str]) -> int:\n length = len(A)\n res = set()\n for item in A:\n odds = item[::2]\n evens = item[1::2]\n res.add((str(sorted(odds)),str(sorted(evens))))\n return len(res)\n```
1
0
[]
1
groups-of-special-equivalent-strings
c++ beat 99% with explanation
c-beat-99-with-explanation-by-barorz-g7ii
\tafter realizing the question, all we have to do is the check if odd/even position pattern is the same between two string.\n\tfor instance : "abcdefggyy"\n\tod
barorz
NORMAL
2019-05-27T07:30:25.936459+00:00
2019-05-27T07:34:05.717241+00:00
201
false
\tafter realizing the question, all we have to do is the check if odd/even position pattern is the same between two string.\n\tfor instance : "abcdefggyy"\n\todd pattern : "acegy"\n\teven pattern : "bdfgy"\n\twe can simply check those pattern after sorting.\n\n```\nclass Solution {\npublic:\n int numSpecialEquivGrou...
1
0
[]
0
mini-parser
An Java Iterative Solution
an-java-iterative-solution-by-alexthegre-sc7f
This approach will just iterate through every char in the string (no recursion).\n If encounters '[', push current NestedInteger to stack and start a new one.\n
alexthegreat
NORMAL
2016-08-14T18:30:49.969000+00:00
2018-10-25T23:29:41.313662+00:00
28,565
false
This approach will just iterate through every char in the string (no recursion).\n* If encounters '[', push current NestedInteger to stack and start a new one.\n* If encounters ']', end current NestedInteger and pop a NestedInteger from stack to continue.\n* If encounters ',', append a new number to curr NestedInteger,...
116
0
[]
19
mini-parser
Python & C++ solutions
python-c-solutions-by-stefanpochmann-nxiu
Python using eval:\n\n def deserialize(self, s):\n def nestedInteger(x):\n if isinstance(x, int):\n return NestedInteger(x)\
stefanpochmann
NORMAL
2016-08-14T15:00:24.807000+00:00
2018-10-19T19:11:43.069539+00:00
17,409
false
## Python using `eval`:\n\n def deserialize(self, s):\n def nestedInteger(x):\n if isinstance(x, int):\n return NestedInteger(x)\n lst = NestedInteger()\n for y in x:\n lst.add(nestedInteger(y))\n return lst\n return nestedIntege...
78
0
['Recursion', 'Python', 'C++']
10
mini-parser
C++ Non-Recursive One-Pass Solution (using Stack) || A Possible Implementation of NestedInteger
c-non-recursive-one-pass-solution-using-mcdxv
Solution in a Glance:\nThis solution uses a stack to record the NestedInteger's.\nAt the very beginning, an empty NestedInteger is placed in the stack. This Nes
zhiqing_xiao
NORMAL
2016-08-20T15:46:50.347000+00:00
2018-09-28T18:48:40.865593+00:00
7,539
false
**Solution in a Glance:**\nThis solution uses a stack to record the NestedInteger's.\nAt the very beginning, an empty NestedInteger is placed in the stack. This NestedInteger will be regarded as a list that holds one but only one NestedInteger, which will be returned in the end.\n*Logic:* When encountering '[', the sta...
54
0
['C']
7
mini-parser
Python O(N) one pass iterative solution
python-on-one-pass-iterative-solution-by-ah5a
\nclass Solution:\n def deserialize(self, s):\n stack, num, last = [], "", None\n for c in s:\n if c.isdigit() or c == "-": num += c
cenkay
NORMAL
2018-08-03T14:57:04.245763+00:00
2018-10-06T06:52:27.703773+00:00
2,638
false
```\nclass Solution:\n def deserialize(self, s):\n stack, num, last = [], "", None\n for c in s:\n if c.isdigit() or c == "-": num += c\n elif c == "," and num:\n stack[-1].add(NestedInteger(int(num)))\n num = ""\n elif c == "[":\n ...
42
1
[]
1
mini-parser
A top down parser using c++
a-top-down-parser-using-c-by-moevery-sq08
c++\nclass Solution {\npublic:\n NestedInteger deserialize(string s) {\n int index = 0;\n char c = s[index];\n if (c == '[') {\n
moevery
NORMAL
2016-08-14T14:43:03.076000+00:00
2016-08-14T14:43:03.076000+00:00
4,766
false
```c++\nclass Solution {\npublic:\n NestedInteger deserialize(string s) {\n int index = 0;\n char c = s[index];\n if (c == '[') {\n return parseList(s, index);\n } else {\n // starts with 0-9, '-'\n return parseNumber(s, index);\n }\n }\n \n ...
37
1
[]
2
mini-parser
Short Java recursive solution
short-java-recursive-solution-by-mylzsd-1a62
\n\npublic class Solution {\n public NestedInteger deserialize(String s) {\n NestedInteger ret = new NestedInteger();\n if (s == null || s.leng
mylzsd
NORMAL
2016-08-14T19:39:09.151000+00:00
2018-10-06T01:41:25.067063+00:00
5,898
false
\n```\npublic class Solution {\n public NestedInteger deserialize(String s) {\n NestedInteger ret = new NestedInteger();\n if (s == null || s.length() == 0) return ret;\n if (s.charAt(0) != '[') {\n ret.setInteger(Integer.parseInt(s));\n }\n else if (s.length() > 2) {\n ...
32
1
[]
2
mini-parser
Java Solution using Stack. logic same same as basic calculator question
java-solution-using-stack-logic-same-sam-vovi
\n public NestedInteger deserialize(String s) {\n if(s == null || s.isEmpty()) return new NestedInteger();\n Stack<NestedInteger> stack = new S
vvv_vvv
NORMAL
2016-08-15T15:53:34.819000+00:00
2018-08-27T21:00:04.823329+00:00
2,120
false
```\n public NestedInteger deserialize(String s) {\n if(s == null || s.isEmpty()) return new NestedInteger();\n Stack<NestedInteger> stack = new Stack<>();\n int sign = 1, len = s.length() ;\n for(int i = 0 ; i < len ; i++){\n char c = s.charAt(i);\n if(c == '['){\n ...
24
0
[]
4
mini-parser
Straightforward Java solution with explanation and a simple implementation of NestedInteger for your ease of testing
straightforward-java-solution-with-expla-97ka
Also viewable here.\n\nThe idea is very straightforward:\n\n1. if it's '[', we just construct a new nested integer and push it onto the stack\n\n2. if it's a nu
fishercoder
NORMAL
2016-08-14T18:21:09.775000+00:00
2016-08-14T18:21:09.775000+00:00
5,912
false
Also viewable [here](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/MiniParser.java).\n\nThe idea is very straightforward:\n\n1. if it's '[', we just construct a new nested integer and push it onto the stack\n\n2. if it's a number, we parse the whole number and add to th...
18
1
[]
1
mini-parser
385: Time 92.59% and Space 97.53%, Solution with step by step explanation
385-time-9259-and-space-9753-solution-wi-akwi
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n1. We start by checking if the input string s starts with a [. If it does
Marlen09
NORMAL
2023-03-04T06:48:00.537340+00:00
2023-03-04T06:48:00.537396+00:00
1,783
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n1. We start by checking if the input string s starts with a [. If it doesn\'t, then it must be a single integer, so we create a NestedInteger object with that value and return it.\n\n```\nif s[0] != \'[\':\n return NestedIn...
14
0
['String', 'Stack', 'Depth-First Search', 'Python', 'Python3']
2
mini-parser
Very short recursive solution
very-short-recursive-solution-by-quesder-a6al
```\nclass Solution {\npublic: \n NestedInteger parse(string& s, int& i) {\n if(s[i]=='[') {\n ++i;\n NestedInteger list;\n
quesder
NORMAL
2016-08-28T04:15:14.402000+00:00
2016-08-28T04:15:14.402000+00:00
1,401
false
```\nclass Solution {\npublic: \n NestedInteger parse(string& s, int& i) {\n if(s[i]=='[') {\n ++i;\n NestedInteger list;\n while(s[i] != ']') {\n list.add(parse(s,i));\n if(s[i] ==',') ++i;\n }\n ++i;\n return list;\n } else...
14
0
[]
1
mini-parser
Python iterative solution with stack and dummy NestedInteger
python-iterative-solution-with-stack-and-v6sb
from collections import deque\n\n class Solution(object):\n def deserialize(self, s):\n """\n :type s: str\n :rtype:
asdfasdf
NORMAL
2016-08-14T14:52:24.794000+00:00
2018-09-06T14:42:45.920725+00:00
2,289
false
from collections import deque\n\n class Solution(object):\n def deserialize(self, s):\n """\n :type s: str\n :rtype: NestedInteger\n """\n initial = NestedInteger()\n q = deque()\n q.append(initial)\n i = 0\n\n ...
13
0
[]
3
mini-parser
C++ Clean and Elegant Code with Clear logic
c-clean-and-elegant-code-with-clear-logi-7jaq
```cs\nclass Solution {\n NestedInteger parse(const string &s, int & pos)\n {\n if (s[pos] == '[')\n return parseList(s, pos);\n
fentoyal
NORMAL
2016-08-27T18:29:49.720000+00:00
2016-08-27T18:29:49.720000+00:00
2,208
false
```cs\nclass Solution {\n NestedInteger parse(const string &s, int & pos)\n {\n if (s[pos] == '[')\n return parseList(s, pos);\n return parseNum(s, pos);\n }\n NestedInteger parseNum(const string &s, int & pos)\n {\n int num = 0;\n int sign = s[pos] == '-' ? -1 : 1;...
12
0
['C']
1
mini-parser
Python | Recursion | 1 Pass | Simplest Solution
python-recursion-1-pass-simplest-solutio-mit6
\nclass Solution:\n def parseNumber(self, s, idx, isNegative=False):\n num = 0\n while idx < len(s) and s[idx].isdigit():\n num = nu
akash3anup
NORMAL
2022-05-17T09:11:39.441239+00:00
2022-05-17T09:16:00.687722+00:00
691
false
```\nclass Solution:\n def parseNumber(self, s, idx, isNegative=False):\n num = 0\n while idx < len(s) and s[idx].isdigit():\n num = num*10 + int(s[idx])\n idx += 1\n if isNegative:\n num = -num\n return NestedInteger(num), idx\n \n def parseList(sel...
8
0
['Recursion', 'Python']
1
mini-parser
Short and Clean Java Recursive Solution with Explanation
short-and-clean-java-recursive-solution-i5g4c
Using the "lvl" variable to track if we are inside an inner integer.\nUsing lIndex to track the leftmost start position.\nEvery time the program hit the "[" inc
lzmshiwo
NORMAL
2016-09-15T23:06:41.897000+00:00
2016-09-15T23:06:41.897000+00:00
1,376
false
Using the "lvl" variable to track if we are inside an inner integer.\nUsing lIndex to track the leftmost start position.\nEvery time the program hit the "[" increase lvl, and decrease lvl when hit "]"\nWhen the program meets ","\n If lvl != 0, ignore the "," since we are inside a nested integer\n else do recu...
8
0
[]
1
mini-parser
Python | 8 lines of code, built-in json parser.
python-8-lines-of-code-built-in-json-par-h0rk
Formal background.\n\nThe language we have to parse isn\'t regular (https://en.wikipedia.org/wiki/Regular_language), so we can\'t use a regex. Rather, the langu
float4
NORMAL
2021-11-14T21:41:08.314104+00:00
2021-11-14T21:41:08.314141+00:00
1,088
false
# Formal background.\n\nThe language we have to parse isn\'t regular (https://en.wikipedia.org/wiki/Regular_language), so we can\'t use a regex. Rather, the language is context-free (https://en.wikipedia.org/wiki/Context-free_language). As we don\'t have access to a Context-Free Grammar parser module in python, we woul...
6
1
['Python']
0
mini-parser
Simple Java Solution (Beats 98%)
simple-java-solution-beats-98-by-fabrizi-q3m6
Basic idea:\nThe Nested Integer is composed an Integer or a List;\n\n- If it is a List (starts with [), then for each element of the list, (Integer or nested Li
fabrizio3
NORMAL
2016-12-10T12:35:41.125000+00:00
2016-12-10T12:35:41.125000+00:00
1,459
false
Basic idea:\nThe Nested Integer is composed an Integer or a List;\n\n- If it is a List (starts with `[`), then for each element of the list, (Integer or nested List) call `deserialize()` and add the result of `deserialize()` to the current NestedInteger.\n- If it is an Integer, just add it as Nested Integer with single...
6
0
['Recursion', 'Java']
0
mini-parser
Easy Python recursive solution and stack solution, please be careful about time complexity
easy-python-recursive-solution-and-stack-uhuk
\nclass Solution(object):\n def deserialize(self, s):\n """\n :type s: str\n :rtype: NestedInteger\n """\n if s[0] != '[':
pushazhiniao
NORMAL
2016-08-14T17:06:25.075000+00:00
2018-09-24T07:31:28.391392+00:00
1,519
false
```\nclass Solution(object):\n def deserialize(self, s):\n """\n :type s: str\n :rtype: NestedInteger\n """\n if s[0] != '[':\n return NestedInteger(int(s))\n nested = NestedInteger()\n numP, start = 0, 1\n for i in range(1, len(s)):\n if ...
5
0
[]
3
mini-parser
Python Solution just 6 lines || Easy to understand approach || Using eval
python-solution-just-6-lines-easy-to-und-ejnr
\nclass Solution:\n def deserialize(self, s: str) -> NestedInteger:\n\t\t# eval("[1,2,3]") => [1,2,3] it\'ll convert string of list to list\n return s
mohitsatija
NORMAL
2023-02-08T15:14:00.351525+00:00
2023-02-08T15:14:00.351562+00:00
958
false
```\nclass Solution:\n def deserialize(self, s: str) -> NestedInteger:\n\t\t# eval("[1,2,3]") => [1,2,3] it\'ll convert string of list to list\n return self.find(eval(s))\n \n def find(self,s):\n\t\t# if our elment s is type of int we\'ll return new NestedInteger of that value\n if type(s) == typ...
4
0
['Depth-First Search', 'Recursion', 'Python', 'Python3']
2
mini-parser
Java | 2 different Stack solutions | Explained!
java-2-different-stack-solutions-explain-gam6
There are two ways we can make stack solution works and they work rather differently. The first way is slightly more optimal but they both run in O(n).\n1. Init
Student2091
NORMAL
2022-04-14T20:37:20.667624+00:00
2022-04-14T20:39:20.347975+00:00
849
false
There are two ways we can make stack solution works and they work rather differently. The first way is slightly more optimal but they both run in O(n).\n1. Initialize a new NestedList at the start and set it to `cur`\n\n2. Everytime we encounter `\'[\'`, we push `cur` onto the stack and set `cur` to be a new NestedList...
4
0
['Stack', 'Java']
1
mini-parser
C++ Stack | Concise
c-stack-concise-by-chenzhiyin1988-dytj
\nNestedInteger deserialize(string s) {\n if(s[0] != \'[\') return NestedInteger(stoi(s));\n \n stack<NestedInteger> stk;\n string num = "";\n for(cha
chenzhiyin1988
NORMAL
2021-09-27T04:54:33.436809+00:00
2022-03-12T03:04:13.206946+00:00
184
false
```\nNestedInteger deserialize(string s) {\n if(s[0] != \'[\') return NestedInteger(stoi(s));\n \n stack<NestedInteger> stk;\n string num = "";\n for(char c: s) {\n if(c == \'[\') {\n stk.push(NestedInteger());\n }\n else if(c == \']\' || c == \',\') {\n if(num != "") {\n...
4
0
[]
1
mini-parser
very short java solution
very-short-java-solution-by-rayszhangqq-j983
\n public NestedInteger deserialize(String s) {\n if (s.contains("[")) {\n NestedInteger ans=new NestedInteger();\n if (s.length
rayszhangqq
NORMAL
2016-08-19T22:45:17.178000+00:00
2016-08-19T22:45:17.178000+00:00
1,219
false
```\n public NestedInteger deserialize(String s) {\n if (s.contains("[")) {\n NestedInteger ans=new NestedInteger();\n if (s.length()>2) {\n int begin=1;\n char[] cs=s.toCharArray();\n int count=0;\n for (int i = 1; i < s.length...
4
0
[]
1
mini-parser
Python recursive solution
python-recursive-solution-by-notebook-je0k
A python recursive solution:\nFirst, determine the type of parsing: two scenarios can be met:\n1. the first character of a given string is '[': to parse a list.
notebook
NORMAL
2016-08-15T18:16:32.007000+00:00
2016-08-15T18:16:32.007000+00:00
578
false
A python recursive solution:\nFirst, determine the type of parsing: two scenarios can be met:\n1. the first character of a given string is '[': to parse a list.\nWhenever '[' is met, start parsing a list and end when ']' is met.\n2. otherwise: to parse a simple integer.\nThe recursive function should return the parsed ...
4
0
[]
1
mini-parser
Solution By Dare2Solve | Detailed Explanation | Clean Code
solution-by-dare2solve-detailed-explanat-78qo
Explanation []\nauthorslog.com/blog/aw46KFc7BX\n\n# Code\n\ncpp []\n// Assuming the NestedInteger class is defined like this:\n// class NestedInteger {\n// publ
Dare2Solve
NORMAL
2024-09-11T18:12:44.940996+00:00
2024-09-11T18:12:44.941046+00:00
709
false
```Explanation []\nauthorslog.com/blog/aw46KFc7BX\n```\n# Code\n\n```cpp []\n// Assuming the NestedInteger class is defined like this:\n// class NestedInteger {\n// public:\n// NestedInteger() {}; // Initializes an empty list\n// NestedInteger(int value) {}; // Initializes a singl...
3
0
['Stack', 'Depth-First Search', 'Python', 'C++', 'Java', 'Python3', 'JavaScript']
0
mini-parser
c++ |easy to understand | short
c-easy-to-understand-short-by-venomhighs-0o7c
\n# Code\n\n/**\n * // This is the interface that allows for creating nested lists.\n * // You should not implement it, or speculate about its implementation\n
venomhighs7
NORMAL
2022-10-07T11:27:42.348043+00:00
2022-10-07T11:27:42.348077+00:00
1,222
false
\n# Code\n```\n/**\n * // This is the interface that allows for creating nested lists.\n * // You should not implement it, or speculate about its implementation\n * class NestedInteger {\n * public:\n * // Constructor initializes an empty nested list.\n * NestedInteger();\n *\n * // Constructor initialize...
3
0
['C++']
0
mini-parser
Go 0ms
go-0ms-by-dynasty919-hhb2
\nfunc deserialize(s string) *NestedInteger {\n \n stack := []*NestedInteger{}\n \n i := 0\n for i < len(s) {\n switch {\n case
dynasty919
NORMAL
2020-08-15T18:05:33.203318+00:00
2020-08-15T18:13:19.733650+00:00
108
false
```\nfunc deserialize(s string) *NestedInteger {\n \n stack := []*NestedInteger{}\n \n i := 0\n for i < len(s) {\n switch {\n case s[i] == \'[\':\n stack = append(stack, &NestedInteger{})\n \n case s[i] == \']\':\n if len(stack) == 1 {\n ...
3
0
[]
0
mini-parser
Recursive solution but clean and simple code in C
recursive-solution-but-clean-and-simple-hddpu
\nstruct NestedInteger* deserializeUtil(char** s) {\n struct NestedInteger *ni = NestedIntegerInit(), *num_ni = NULL;\n char *end = NULL;\n \n if(**
brickell
NORMAL
2018-02-10T07:54:32.412000+00:00
2018-02-10T07:54:32.412000+00:00
222
false
```\nstruct NestedInteger* deserializeUtil(char** s) {\n struct NestedInteger *ni = NestedIntegerInit(), *num_ni = NULL;\n char *end = NULL;\n \n if(**s != '['){\n NestedIntegerSetInteger(ni, strtoul(*s, NULL, 0));\n return ni;\n }\n \n if(**s == '[') (*s)++;\n \n while(**s != '...
3
0
[]
0
mini-parser
Java iterative and recursive (including one-pass) solution
java-iterative-and-recursive-including-o-b8h5
Both are straight forward.\n\n\n public NestedInteger deserialize(String s) {\n if (s.charAt(0) != '[') return new NestedInteger(Integer.parseInt(s));
iaming
NORMAL
2016-08-17T00:38:39.388000+00:00
2018-08-21T22:01:29.947526+00:00
1,129
false
Both are straight forward.\n\n```\n public NestedInteger deserialize(String s) {\n if (s.charAt(0) != '[') return new NestedInteger(Integer.parseInt(s));\n NestedInteger cur = new NestedInteger();\n Stack<NestedInteger> stack = new Stack<>();\n for (int i = 1, start = 1; i < s.length(); +...
3
0
[]
2
mini-parser
Clean Iterative Java Solution using Stack
clean-iterative-java-solution-using-stac-weyj
\npublic class Solution {\n public NestedInteger deserialize(String s) {\n String[] tokens = s.split(",");\n Stack<NestedInteger> stack = new S
wcyz666
NORMAL
2016-08-26T01:17:29.010000+00:00
2016-08-26T01:17:29.010000+00:00
477
false
```\npublic class Solution {\n public NestedInteger deserialize(String s) {\n String[] tokens = s.split(",");\n Stack<NestedInteger> stack = new Stack();\n NestedInteger root = new NestedInteger();\n stack.push(root);\n \n for (String token: tokens) {\n int start ...
3
0
[]
1
mini-parser
Recursive Python solution with explanation
recursive-python-solution-with-explanati-whpb
Intuition\nSplit the tokens and recursively process them.\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n1. If the string does not
zerocores
NORMAL
2024-02-15T14:32:03.597078+00:00
2024-02-15T14:32:03.597107+00:00
175
false
# Intuition\nSplit the tokens and recursively process them.\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n1. If the string does not start with `[`, it\'s a scalar.\n2. If it\'s a list, split the string into tokens(elements) and recursively process them.\n3. If there\'s a nested lis...
2
0
['Python3']
0
mini-parser
[Python] eval
python-eval-by-pbelskiy-6ahv
python\nclass Solution:\n def deserialize(self, s: str) -> NestedInteger:\n \n def dfs(obj):\n if isinstance(obj, int):\n
pbelskiy
NORMAL
2023-11-22T20:22:39.501373+00:00
2023-11-22T20:22:39.501396+00:00
164
false
```python\nclass Solution:\n def deserialize(self, s: str) -> NestedInteger:\n \n def dfs(obj):\n if isinstance(obj, int):\n return NestedInteger(obj)\n\n ni = NestedInteger() \n for el in obj:\n if isinstance(el, list):\n ...
2
0
['Depth-First Search', 'Python']
0
mini-parser
Mini Parser Solution Java
mini-parser-solution-java-by-bhupendra78-ykm3
class Solution {\n public NestedInteger deserialize(String s) {\n if (s.charAt(0) != \'[\')\n return new NestedInteger(Integer.parseInt(s));\n\n Deq
bhupendra786
NORMAL
2022-09-17T09:46:32.023240+00:00
2022-09-17T09:46:32.023279+00:00
623
false
class Solution {\n public NestedInteger deserialize(String s) {\n if (s.charAt(0) != \'[\')\n return new NestedInteger(Integer.parseInt(s));\n\n Deque<NestedInteger> stack = new ArrayDeque<>();\n int start = 1;\n\n for (int i = 0; i < s.length(); ++i)\n switch (s.charAt(i)) {\n case \'[\':...
2
0
['String', 'Stack', 'Depth-First Search']
0
mini-parser
javascript easy dfs 174ms
javascript-easy-dfs-174ms-by-henrychen22-6e3w
\nconst deserialize = (s) => {\n let a = JSON.parse(s);\n return dfs(a);\n};\n\nconst dfs = (input) => {\n if (Number.isInteger(input)) return new Nest
henrychen222
NORMAL
2022-02-08T18:50:36.613417+00:00
2022-02-08T18:52:26.318847+00:00
499
false
```\nconst deserialize = (s) => {\n let a = JSON.parse(s);\n return dfs(a);\n};\n\nconst dfs = (input) => {\n if (Number.isInteger(input)) return new NestedInteger(input); // if (!Array.isArray(input)) return new NestedInteger(input); also works\n let l = new NestedInteger();\n for (const e of input) l.a...
2
0
['Depth-First Search', 'Recursion', 'JavaScript']
1
mini-parser
python recursive
python-recursive-by-hzhaoc-qqx7
\nclass Solution:\n def deserialize(self, s: str) -> NestedInteger:\n def search(i, s):\n res, j = NestedInteger(), i\n while i
hzhaoc
NORMAL
2021-11-12T22:48:04.584560+00:00
2021-11-12T22:48:04.584587+00:00
94
false
```\nclass Solution:\n def deserialize(self, s: str) -> NestedInteger:\n def search(i, s):\n res, j = NestedInteger(), i\n while i < len(s):\n if s[i].isdigit() or s[i] == \'-\':\n i += 1\n elif s[i] == \',\':\n if j < i...
2
0
[]
0
mini-parser
Java | Stack | explanation
java-stack-explanation-by-qin10-7lzk
```\nclass Solution {\n public NestedInteger deserialize(String s) {\n if(s.charAt(0) != \'[\') return new NestedInteger(Integer.parseInt(s));\n
qin10
NORMAL
2021-10-21T16:19:21.740462+00:00
2021-10-21T16:21:00.334839+00:00
178
false
```\nclass Solution {\n public NestedInteger deserialize(String s) {\n if(s.charAt(0) != \'[\') return new NestedInteger(Integer.parseInt(s));\n \n NestedInteger root = new NestedInteger();\n Deque<NestedInteger> stack = new ArrayDeque<NestedInteger>();\n stack.push(root);\n ...
2
0
[]
0
mini-parser
[Python3] a concise recursive solution
python3-a-concise-recursive-solution-by-qjsrf
\n\nclass Solution:\n def deserialize(self, s: str) -> NestedInteger:\n if not s: return NestedInteger()\n if not s.startswith("["): return Nes
ye15
NORMAL
2020-10-02T21:09:21.783483+00:00
2020-10-02T21:09:21.783514+00:00
410
false
\n```\nclass Solution:\n def deserialize(self, s: str) -> NestedInteger:\n if not s: return NestedInteger()\n if not s.startswith("["): return NestedInteger(int(s)) # integer \n ans = NestedInteger()\n s = s[1:-1] # strip outer "[" and "]"\n if s: \n ii = op = 0 \n ...
2
0
['Python3']
0
mini-parser
Java stack solution easy to understand
java-stack-solution-easy-to-understand-b-t5pz
1 Everything will be pushed to stack, so no extra pointers or references needed (will get messy if there are many pointers)\n2 If there is a \'[\', the nestedIn
ritaccc
NORMAL
2020-09-10T21:31:40.066891+00:00
2020-09-10T21:31:40.066934+00:00
265
false
1 Everything will be pushed to stack, so no extra pointers or references needed (will get messy if there are many pointers)\n2 If there is a \'[\', the nestedInteger will be a list, so just add a list.\n3 if there is a num, it will be an integer, so get the list from stack, and add the integer to the stack\n4 if there ...
2
0
[]
1
mini-parser
Swift: SIMPLE & SWEET, 100%
swift-simple-sweet-100-by-voxqhuy-nse0
\nfunc deserialize(_ s: String) -> NestedInteger {\n\tif s.first != "[" {\n\t\treturn NestedInteger(Int(s))\n\t}\n\n\tvar stack = [NestedInteger]()\n\tvar resul
voxqhuy
NORMAL
2020-08-21T22:31:22.304858+00:00
2020-08-21T22:31:22.304894+00:00
118
false
```\nfunc deserialize(_ s: String) -> NestedInteger {\n\tif s.first != "[" {\n\t\treturn NestedInteger(Int(s))\n\t}\n\n\tvar stack = [NestedInteger]()\n\tvar result = NestedInteger()\n\tstack.append(result)\n\tvar curInt = ""\n\n\tfor char in s.dropFirst() {\n\t\tif char == "[" {\n\t\t\tvar ni = NestedInteger()\n\t\t\t...
2
0
['Swift']
0
mini-parser
Very simple 7 line solution in java
very-simple-7-line-solution-in-java-by-r-iv4s
There are 2 cases\n1. list\n2. number\n\nFor the list case, call recursively.\n\n\npublic NestedInteger deserialize(String s) {\n\tNestedInteger ans = new Neste
rishirdua
NORMAL
2019-04-23T07:39:30.692576+00:00
2019-04-23T07:39:30.692621+00:00
191
false
There are 2 cases\n1. list\n2. number\n\nFor the list case, call recursively.\n\n```\npublic NestedInteger deserialize(String s) {\n\tNestedInteger ans = new NestedInteger();\n\tif (s.charAt(0) == \'[\') { // list\n\t\tArrays.stream(s.substring(1, s.length()-1).split(","))\n\t\t\t .forEach(a -> ans.add(deserialize(a)...
2
0
[]
0
mini-parser
c++ stack 100%, がんばります!
c-stack-100-ganbarimasu-by-solaaoi-d3rt
\n/**\n * // This is the interface that allows for creating nested lists.\n * // You should not implement it, or speculate about its implementation\n * class Ne
solaaoi
NORMAL
2018-09-14T18:06:10.510502+00:00
2018-09-14T18:06:10.510548+00:00
302
false
```\n/**\n * // This is the interface that allows for creating nested lists.\n * // You should not implement it, or speculate about its implementation\n * class NestedInteger {\n * public:\n * // Constructor initializes an empty nested list.\n * NestedInteger();\n *\n * // Constructor initializes a single...
2
0
[]
0
mini-parser
Java solution
java-solution-by-octoray-r03s
\npublic class Solution {\n\n\tpublic NestedInteger deserialize(String s) {\n\t\tint len = s.length();\n\t\tif (!s.startsWith("[")) {\n\t\t\tNestedInteger ni =
octoray
NORMAL
2018-05-05T20:17:57.169672+00:00
2018-08-27T20:34:14.405369+00:00
479
false
```\npublic class Solution {\n\n\tpublic NestedInteger deserialize(String s) {\n\t\tint len = s.length();\n\t\tif (!s.startsWith("[")) {\n\t\t\tNestedInteger ni = new NestedInteger(Integer.parseInt(s));\n\t\t\treturn ni;\n\t\t}\n\t\tNestedInteger root = new NestedInteger();\n\t\tStack<NestedInteger> stack = new Stack<>...
2
0
[]
2
mini-parser
Share my simple JAVA solution with explanation
share-my-simple-java-solution-with-expla-ocvt
Basic idea is: \n1) when you see '[' you know you have to create a new NextedInteger object, but before that you have to store, if any, your current work into s
bbccyy1
NORMAL
2016-08-14T15:13:22.735000+00:00
2016-08-14T15:13:22.735000+00:00
797
false
Basic idea is: \n1) when you see '[' you know you have to create a new NextedInteger object, but before that you have to store, if any, your current work into stack (we use stack structure to preserve the input order)\n2) when you see ']' you can close current work and add it to the first element in stack, then replace...
2
0
[]
0
mini-parser
Extremely simple Python solution
extremely-simple-python-solution-by-peng-0imj
python\nclass Solution(object):\n def deserialize(self, s):\n """\n :type s: str\n :rtype: NestedInteger\n """\n return ev
pengge
NORMAL
2016-08-25T12:36:20.375000+00:00
2016-08-25T12:36:20.375000+00:00
288
false
```python\nclass Solution(object):\n def deserialize(self, s):\n """\n :type s: str\n :rtype: NestedInteger\n """\n return eval(s)\n```\nThis code could pass the test cases. But I don't know whether this solution is legal or not.
2
1
[]
0
mini-parser
C++ iterative solution
c-iterative-solution-by-soamaaazing-gmnp
Construct NestedInteger while parsing the string s:\n\n NestedInteger deserialize(string s) {\n stack<NestedInteger> st;\n int num = 0, sign =
soamaaazing
NORMAL
2016-08-26T01:36:41.011000+00:00
2016-08-26T01:36:41.011000+00:00
486
false
Construct NestedInteger while parsing the string s:\n```\n NestedInteger deserialize(string s) {\n stack<NestedInteger> st;\n int num = 0, sign = 1; \n bool numValid = false;\n \n for (int i = 0; i < s.length(); i++) {\n if (s[i] == '-') {\n sign = -1; ...
2
0
[]
0
mini-parser
my solution using formal grammar. long but elegant in my opinion...
my-solution-using-formal-grammar-long-bu-p5qj
\n/**\n * grammar for the context.\n * NestedInteger := Number | [InnerNestedIneger]\n * InnerNestedInteger := NestedInteger | InnerNestedInte
alvisjiang
NORMAL
2016-08-28T13:23:24.458000+00:00
2016-08-28T13:23:24.458000+00:00
310
false
```\n/**\n * grammar for the context.\n * NestedInteger := Number | [InnerNestedIneger]\n * InnerNestedInteger := NestedInteger | InnerNestedInteger,NestedInteger\n * Number := -PositiveNumber | PositiveNumber\n * PositiveNumber := digit | digitPositiveNumber\n */\npublic...
2
0
[]
1
mini-parser
Python recursive solution
python-recursive-solution-by-johnnydu-9064
\nclass Solution(object):\n def deserialize(self, s):\n """\n :type s: str\n :rtype: NestedInteger\n """\n try:\n
johnnydu
NORMAL
2016-10-12T01:06:09.934000+00:00
2016-10-12T01:06:09.934000+00:00
317
false
```\nclass Solution(object):\n def deserialize(self, s):\n """\n :type s: str\n :rtype: NestedInteger\n """\n try:\n return int(s)\n except:\n i, open_paren, result = 1, 0, []\n for j in range(1, len(s)-1):\n if s[j] == ',' and...
2
0
[]
0
mini-parser
Java solution using StringTokenizer and Stack, easy and clear logic
java-solution-using-stringtokenizer-and-c31pc
\nimport java.util.StringTokenizer;\npublic class Solution {\n\n public NestedInteger deserialize(String s) {\n StringTokenizer tokenizer = new String
xamous
NORMAL
2017-01-05T15:14:12.144000+00:00
2017-01-05T15:14:12.144000+00:00
528
false
```\nimport java.util.StringTokenizer;\npublic class Solution {\n\n public NestedInteger deserialize(String s) {\n StringTokenizer tokenizer = new StringTokenizer(s, "[],", true);\n\n Stack<NestedInteger> stack = new Stack<>();\n stack.push(new NestedInteger()); // a dummy list to simplify init\...
2
0
[]
1
mini-parser
Elegant Python one-pass solution, beats 93%, easy to understand
python-one-pass-solution-build-answer-ch-tckx
IntuitionRead string from left to right, char by char, remember context when necessary -- just like a normal human being.Complexity Time complexity:O(n) Space c
guozhenli
NORMAL
2025-02-20T09:14:40.245662+00:00
2025-02-22T06:33:04.156116+00:00
205
false
# Intuition Read string from left to right, char by char, remember context when necessary -- just like a normal human being. # Complexity - Time complexity: $$O(n)$$ - Space complexity: $$O(n)$$ # Code ```python3 [] class Solution: def deserialize(self, s: str) -> NestedInteger: context = None i...
1
0
['Python3']
0
mini-parser
Recursion - Java O(N)|O(1)
recursion-java-ono1-by-wangcai20-4wzz
Intuition\n Describe your first thoughts on how to solve this problem. \nOne pass scan from left to right and chop at each , at root level:\n if chopped section
wangcai20
NORMAL
2024-10-23T16:20:27.658680+00:00
2024-10-23T16:21:04.310585+00:00
79
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nOne pass scan from left to right and chop at each `,` at root level:\n* if chopped section is number, add a `Integer` type of NestedInteger.\n* if chopped section is list, add a `List` type of NestedInteger.\n\n# Approach\n<!-- Describe y...
1
0
['Java']
0
mini-parser
C++ easy solution
c-easy-solution-by-chandleryeh-44rt
Intuition\nNested Solution with golbal counter\nwhen encounter \'[\', enter nested\nwhen encounter \']\', leave nested\n\n# Code\n\n/**\n * // This is the inter
chandleryeh
NORMAL
2024-06-16T13:05:20.726888+00:00
2024-06-16T13:05:20.726916+00:00
350
false
# Intuition\nNested Solution with golbal counter\nwhen encounter \'[\', enter nested\nwhen encounter \']\', leave nested\n\n# Code\n```\n/**\n * // This is the interface that allows for creating nested lists.\n * // You should not implement it, or speculate about its implementation\n * class NestedInteger {\n * publi...
1
0
['C++']
0
mini-parser
Recursive parser
recursive-parser-by-vokasik-1xl4
\nclass Solution:\n def deserialize(self, s: str) -> NestedInteger:\n def parse():\n nonlocal i\n lst = NestedInteger()\n
vokasik
NORMAL
2024-06-01T03:00:46.011416+00:00
2024-06-01T03:00:46.011442+00:00
370
false
```\nclass Solution:\n def deserialize(self, s: str) -> NestedInteger:\n def parse():\n nonlocal i\n lst = NestedInteger()\n while i < len(s):\n prev = i\n while s[i] == \'-\' or s[i].isdigit():\n i += 1\n if prev...
1
0
['Python', 'Python3']
0
mini-parser
MOST easy to understand coding
most-easy-to-understand-coding-by-dingoo-tdlg
Intuition\n Describe your first thoughts on how to solve this problem. \n\n\n\n# Code\n\n/**\n * // This is the interface that allows for creating nested lists.
Dingoooooo
NORMAL
2024-03-26T10:46:53.460635+00:00
2024-03-26T10:46:53.460662+00:00
145
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n\n\n# Code\n```\n/**\n * // This is the interface that allows for creating nested lists.\n * // You should not implement it, or speculate about its implementation\n * public interface NestedInteger {\n * // Constructor initializes a...
1
0
['Java']
1
mini-parser
go 1.21, clean code
go-121-clean-code-by-colix-ukee
\nfunc deserialize(s string) *NestedInteger {\n\tstack := []NestedInteger{{}}\n\tfor i := 0; i < len(s); i++ {\n\t\tswitch s[i] {\n\t\tcase \'0\', \'1\', \'2\',
colix
NORMAL
2024-03-09T09:14:26.939079+00:00
2024-03-09T09:14:26.939104+00:00
37
false
```\nfunc deserialize(s string) *NestedInteger {\n\tstack := []NestedInteger{{}}\n\tfor i := 0; i < len(s); i++ {\n\t\tswitch s[i] {\n\t\tcase \'0\', \'1\', \'2\', \'3\', \'4\', \'5\', \'6\', \'7\', \'8\', \'9\', \'-\':\n\t\t\tj := i + 1\n\t\t\tfor ; j < len(s) && unicode.IsDigit(rune(s[j])); j++ {}\n\t\t\tinteger, _ :...
1
0
['Go']
0
mini-parser
Kotlin, 100% on runtime.
kotlin-100-on-runtime-by-lev5-0b7i
Intuition\nUse simple recursion to consume input since it maps organically to the NestedInteger data structure. Also note that [] are guaranteed to be matching
lev5
NORMAL
2024-02-13T19:58:36.950877+00:00
2024-02-13T19:58:36.950912+00:00
192
false
# Intuition\nUse simple recursion to consume input since it maps organically to the `NestedInteger` data structure. Also note that `[]` are guaranteed to be matching.\n\nAdditionally, we try to avoid string manipulation which may result in new objects created. Also prefer raw parsing.\n\n# Approach\nMake recursive fu...
1
0
['Kotlin']
0
mini-parser
DFS + IMPLEMENT DELIMTER FUNCTION || JAVA || 10 MS
dfs-implement-delimter-function-java-10-ylacc
Code\n\nclass Solution {\n public NestedInteger deserialize(String s) {\n if(isInteger(s)) {\n return s.isEmpty() ? new NestedInteger() : n
youssef1998
NORMAL
2023-06-20T20:37:46.842873+00:00
2023-06-20T20:37:46.842889+00:00
552
false
# Code\n```\nclass Solution {\n public NestedInteger deserialize(String s) {\n if(isInteger(s)) {\n return s.isEmpty() ? new NestedInteger() : new NestedInteger(getIntegerValue(s));\n }\n s = removeBrackets(s);\n NestedInteger list = new NestedInteger();\n for (String ch...
1
0
['Java']
0
mini-parser
Java | Recursive solution
java-recursive-solution-by-somesh9827-3xny
NestedInteger can contain Integer or List so handled them sepretly. \n\nclass Solution {\n int c = 0;\n public NestedInteger deserialize(String s) {\n
somesh9827
NORMAL
2022-04-30T12:16:26.213783+00:00
2022-04-30T12:16:26.213812+00:00
158
false
NestedInteger can contain Integer or List so handled them sepretly. \n```\nclass Solution {\n int c = 0;\n public NestedInteger deserialize(String s) {\n char[] chars = s.toCharArray();\n return deserialize(chars);\n }\n \n NestedInteger deserialize(char[] chars) {\n if(chars[c] == \...
1
0
[]
0
mini-parser
Java Recursive Solution
java-recursive-solution-by-kojo-ko88
\nclass Solution {\n public NestedInteger deserialize(String s) {\n if(s.charAt(0) != \'[\') return new NestedInteger(Integer.parseInt(s));\n \
kojo
NORMAL
2022-03-17T10:53:07.101683+00:00
2022-03-17T10:53:07.101711+00:00
149
false
```\nclass Solution {\n public NestedInteger deserialize(String s) {\n if(s.charAt(0) != \'[\') return new NestedInteger(Integer.parseInt(s));\n \n NestedInteger res = new NestedInteger();\n int left = 1, right = s.length() - 1;\n while(left < right){\n int start = left;...
1
0
[]
0
mini-parser
Elegant Python One Pass Solution (using stack)
elegant-python-one-pass-solution-using-s-ozay
\nclass Solution:\n def deserialize(self, s: str) -> NestedInteger:\n stack = []\n integerStr = \'\'\n \n for c in s:\n
RG97
NORMAL
2021-12-20T23:38:09.680690+00:00
2021-12-20T23:38:09.680719+00:00
382
false
```\nclass Solution:\n def deserialize(self, s: str) -> NestedInteger:\n stack = []\n integerStr = \'\'\n \n for c in s:\n if c == \'[\':\n stack.append(NestedInteger())\n elif c == \']\':\n if len(integerStr)>0:\n sta...
1
0
['Stack', 'Python3']
0
mini-parser
Python solution using stack
python-solution-using-stack-by-aaman007-mq56
Using Stack:\n\nclass Solution:\n def deserialize(self, s: str) -> NestedInteger:\n if s.find(\'[\') == -1:\n return NestedInteger(int(s))\
aaman007
NORMAL
2021-11-24T15:24:10.758747+00:00
2021-11-24T15:24:10.758777+00:00
362
false
Using Stack:\n```\nclass Solution:\n def deserialize(self, s: str) -> NestedInteger:\n if s.find(\'[\') == -1:\n return NestedInteger(int(s))\n \n stack = []\n sign = 1\n num = None\n \n for ch in s:\n if ch == \'-\':\n sign = -1\n...
1
0
['Stack', 'Python']
0
mini-parser
Java easy stack solution
java-easy-stack-solution-by-codingpianop-rxwi
\nclass Solution {\n public NestedInteger deserialize(String s) {\n // sb for digit value\n StringBuilder sb = new StringBuilder();\n \n
codingpianoplayer
NORMAL
2021-11-17T20:24:46.981855+00:00
2021-11-17T20:24:46.981893+00:00
146
false
```\nclass Solution {\n public NestedInteger deserialize(String s) {\n // sb for digit value\n StringBuilder sb = new StringBuilder();\n \n Stack<NestedInteger> stack = new Stack<>();\n \n NestedInteger lastList = null;\n \n for (int i = 0; i < s.length(); i++)...
1
0
[]
1
mini-parser
[c++] recursive solution O(N)
c-recursive-solution-on-by-nraptis-f2vn
\nclass Solution {\npublic:\n NestedInteger deserialize(string s) {\n int index = 0;\n return deserialize(s, index);\n }\n \n NestedIn
nraptis
NORMAL
2021-10-19T18:33:26.048612+00:00
2021-10-19T18:33:26.048651+00:00
166
false
```\nclass Solution {\npublic:\n NestedInteger deserialize(string s) {\n int index = 0;\n return deserialize(s, index);\n }\n \n NestedInteger deserialize(string s, int &index) {\n NestedInteger result;\n if (s[index] == \'[\') {\n parseList(s, index, &result);\n ...
1
0
[]
0
mini-parser
Faster than 100%, nice~
faster-than-100-nice-by-370203400-em6p
javascript\nvar deserialize = function(s) {\n if(!s) return null\n s = JSON.parse(s)\n let n = new NestedInteger()\n function fn(nt, s) {\n i
370203400
NORMAL
2021-10-06T11:08:16.184853+00:00
2023-01-08T10:40:50.235823+00:00
251
false
```javascript\nvar deserialize = function(s) {\n if(!s) return null\n s = JSON.parse(s)\n let n = new NestedInteger()\n function fn(nt, s) {\n if(Array.isArray(s)) {\n let a = new NestedInteger()\n for(let item of s) {\n let ret = fn(a, item)\n a.ad...
1
0
['JavaScript']
1
mini-parser
C# no stack easy solution
c-no-stack-easy-solution-by-luanshixia-6big
csharp\npublic NestedInteger Deserialize(string s) {\n\tif (!s.Contains(\'[\')) {\n\t\treturn new NestedInteger(Convert.ToInt32(s));\n\t}\n\tvar list = new Nest
luanshixia
NORMAL
2021-08-11T23:01:38.533359+00:00
2021-08-11T23:01:38.533428+00:00
68
false
```csharp\npublic NestedInteger Deserialize(string s) {\n\tif (!s.Contains(\'[\')) {\n\t\treturn new NestedInteger(Convert.ToInt32(s));\n\t}\n\tvar list = new NestedInteger();\n\ts = s.Substring(1, s.Length - 2);\n\tvar i = 0;\n\tvar j = 0;\n\tvar bracketCounter = 0;\n\twhile (i < s.Length) {\n\t\tif (bracketCounter ==...
1
0
[]
0
mini-parser
Go Easy
go-easy-by-oliver2010-4p1f
\nfunc deserialize(s string) *NestedInteger {\n stk:=[]*NestedInteger{}\n curr:=""\n for _,v:=range s{\n if v==\'[\'{\n //init\n
Oliver2010
NORMAL
2021-08-06T18:21:26.580581+00:00
2021-08-06T18:21:26.580624+00:00
85
false
```\nfunc deserialize(s string) *NestedInteger {\n stk:=[]*NestedInteger{}\n curr:=""\n for _,v:=range s{\n if v==\'[\'{\n //init\n stk=append(stk,&NestedInteger{})\n }else if v==\']\'{\n if curr!=""{\n stk[len(stk)-1].Add(*buildNI(curr))\n ...
1
0
[]
0
mini-parser
Python beat 100% runtime and 99.48% memory recursive solution
python-beat-100-runtime-and-9948-memory-33fc9
\ndef deserialize(self, s: str) -> NestedInteger:\n\n\n\n\tdef helper(new_str, idx, is_list=False):\n\n\t\tstart = idx\n\n\t\tif is_list:\n\t\t\tresult = list()
ashwin_karthik
NORMAL
2021-07-06T16:27:57.570738+00:00
2021-07-06T16:27:57.570781+00:00
99
false
```\ndef deserialize(self, s: str) -> NestedInteger:\n\n\n\n\tdef helper(new_str, idx, is_list=False):\n\n\t\tstart = idx\n\n\t\tif is_list:\n\t\t\tresult = list()\n\t\telse:\n\t\t\tresult = NestedInteger()\n\n\t\tfor cur_idx, ch in enumerate(new_str[idx:]):\n\t\t\tif ch == ",":\n\t\t\t\tni = NestedInteger(new_str[star...
1
0
[]
0
mini-parser
C++ O(n) Stack Solution
c-on-stack-solution-by-mhdareeb-oqty
\nclass Solution {\npublic:\n NestedInteger deserialize(string s)\n {\n NestedInteger ans;\n stack<NestedInteger>st;\n int i=0;\n
mhdareeb
NORMAL
2021-05-24T14:10:27.411824+00:00
2021-05-24T14:10:27.411871+00:00
153
false
```\nclass Solution {\npublic:\n NestedInteger deserialize(string s)\n {\n NestedInteger ans;\n stack<NestedInteger>st;\n int i=0;\n if(s[i]!=\'[\')//just one integer\n {\n ans=NestedInteger(stoi(s));\n return ans;\n }\n while(i<s.size())\n ...
1
0
[]
0
mini-parser
93% :: Python (Eval | Recursion)
93-python-eval-recursion-by-tuhinnn_py-xnuf
\n# """\n# This is the interface that allows for creating nested lists.\n# You should not implement it, or speculate about its implementation\n# """\n#class Nes
tuhinnn_py
NORMAL
2021-05-16T15:21:27.437214+00:00
2021-05-16T15:21:27.437259+00:00
122
false
```\n# """\n# This is the interface that allows for creating nested lists.\n# You should not implement it, or speculate about its implementation\n# """\n#class NestedInteger:\n# def __init__(self, value=None):\n# """\n# If value is not specified, initializes an empty list.\n# Otherwise initializ...
1
0
[]
0
mini-parser
python one pass stack solution
python-one-pass-stack-solution-by-bravep-m8w4
this problem is not clear and kind of broken.\nthe only useful api of the class is __init__ and add, others only make this problem confusing. Took me 20 min eff
bravephoenix
NORMAL
2021-04-10T01:27:09.353410+00:00
2021-04-10T01:30:03.984200+00:00
173
false
this problem is not clear and kind of broken.\nthe only useful api of the class is ```__init__``` and ```add```, others only make this problem confusing. Took me 20 min efforts to guess what the question wants and only 10 min to solve.\nNotice that you have to use ```add(NestedInteger(#num))``` instead of using ```add(...
1
0
[]
1
mini-parser
C++ recursive soln
c-recursive-soln-by-hmqhuange-7jzw
\nRecursive solution, similar to https://leetcode.com/problems/decode-string/\n```\nNestedInteger deserialize(string s) {\n if (s.empty()) return NestedI
hmqhuange
NORMAL
2021-03-21T06:20:42.999036+00:00
2021-03-21T06:20:42.999080+00:00
333
false
\nRecursive solution, similar to https://leetcode.com/problems/decode-string/\n```\nNestedInteger deserialize(string s) {\n if (s.empty()) return NestedInteger();\n if (s[0] != \'[\') return NestedInteger(stoi(s));\n if (s.size() <= 2) return NestedInteger();\n int pos = 1;\n return p...
1
0
['Recursion', 'C']
0
mini-parser
[Java] Recursion, Like N-ary Tree deserializtion
java-recursion-like-n-ary-tree-deseriali-nxyj
\n public NestedInteger deserialize(String s) {\n if(s.charAt(0) == \'[\') {\n NestedInteger root = new NestedInteger();\n s = s
cxhcxh
NORMAL
2021-02-19T17:05:32.916819+00:00
2021-02-19T17:05:32.916862+00:00
146
false
```\n public NestedInteger deserialize(String s) {\n if(s.charAt(0) == \'[\') {\n NestedInteger root = new NestedInteger();\n s = s.substring(1, s.length() - 1); //remove \'[]\'\n \n while(!s.equals("")) {\n if(s.charAt(0) != \'[\') {\n ...
1
0
[]
0
mini-parser
Java using recursion: Time O(N) and Space O(1 except output objects)
java-using-recursion-time-on-and-space-o-1o0h
\nclass Solution {\n \n private int index = 0;\n \n public NestedInteger deserialize(String s) {\n NestedInteger ni = new NestedInteger();\n
solver1318
NORMAL
2021-01-09T23:28:47.177326+00:00
2021-01-09T23:28:47.177368+00:00
141
false
```\nclass Solution {\n \n private int index = 0;\n \n public NestedInteger deserialize(String s) {\n NestedInteger ni = new NestedInteger();\n \n if (s.charAt(index) == \'[\') {\n // ni will be list object\n index++;\n } else {\n // Return simple...
1
0
[]
0
mini-parser
[Java] Short clean code using stack
java-short-clean-code-using-stack-by-shk-1hi6
-, 0-9 means start of an integer so parse it.\n[ means a new NestedInteger begins so push the current one into stack.\n] means current NestedInteger ends so pop
shk10
NORMAL
2020-12-26T22:13:19.343877+00:00
2020-12-26T22:13:19.343918+00:00
396
false
```-, 0-9``` means start of an integer so parse it.\n```[``` means a new NestedInteger begins so push the current one into stack.\n```]``` means current NestedInteger ends so pop from stack to get its parent. Also, add current to parent list. (Alternatively, we could have done this while creating the new NestedInteger....
1
1
['Stack', 'Java']
0
mini-parser
100%/100% Python3, Brute force
100100-python3-brute-force-by-awong05-or4c
This is likely unintended, but I am surprised there aren\'t more posts about how broken this problem is.\n\n\nclass Solution:\n def deserialize(self, s: str)
awong05
NORMAL
2020-09-23T21:17:32.257411+00:00
2020-09-23T21:17:32.257455+00:00
121
false
This is likely unintended, but I am surprised there aren\'t more posts about how broken this problem is.\n\n```\nclass Solution:\n def deserialize(self, s: str) -> NestedInteger:\n return NestedInteger(s)\n```
1
1
[]
1
mini-parser
Detailed Solution to an Ambiguous question. [No wonder why so many dislikes]
detailed-solution-to-an-ambiguous-questi-cv4b
Hi guys this is an ambigious question and no good explaination is available anywhere, here i\'ve heavily commented the code so that the reader can understand, a
geekyanurag
NORMAL
2020-09-01T16:55:53.539157+00:00
2020-09-01T17:02:07.178398+00:00
78
false
Hi guys this is an ambigious question and no good explaination is available anywhere, here i\'ve heavily commented the code so that the reader can understand, also if you have doubts please comment!\ni\'ll create a youtube video on this ans share the link here [];\n\n```\n//NI -- > Nested Integer\nclass Solution {\n ...
1
0
[]
0
mini-parser
[Java] - Clean & Easy to Read
java-clean-easy-to-read-by-philip2207-qh5i
java\npublic static class StringIterator {\n \n\tprivate final String s;\n\tprivate int i;\n\n\tStringIterator(String s) {\n\t\tthis.s = s;\n\t\tthis.i =
philip2207
NORMAL
2020-07-28T12:51:59.416636+00:00
2020-07-28T12:51:59.416669+00:00
431
false
```java\npublic static class StringIterator {\n \n\tprivate final String s;\n\tprivate int i;\n\n\tStringIterator(String s) {\n\t\tthis.s = s;\n\t\tthis.i = 0;\n\t}\n\n\tpublic boolean hasNext() {\n\t\treturn i < s.length();\n\t}\n\n\tpublic char next() {\n\t\tchar c = s.charAt(i);\n\t\ti++;\n\t\treturn c;\n\t}\...
1
0
['Java']
0
mini-parser
Simple Java solution
simple-java-solution-by-irapohlf-t3gi
This seemed complicated at first, but as I implemented, I found that it is not that difficult.\nOn the otherhand, as I said, I couldn\'t figure out the solution
irapohlf
NORMAL
2020-07-11T06:19:09.413552+00:00
2020-07-11T06:19:09.413586+00:00
176
false
This seemed complicated at first, but as I implemented, I found that it is not that difficult.\nOn the otherhand, as I said, I couldn\'t figure out the solution very clearly before start to code, so I might fail if this was my coding question.\n\n```\nclass Solution { \n private boolean isDigit(char ch) {\n ...
1
0
[]
0
mini-parser
C++ recursive slution
c-recursive-slution-by-carpdm-r4c2
C++\nNestedInteger deserialize(string s) {\n \n if (s.size() == 0) return NestedInteger();\n if (s[0] != \'[\') return NestedInteger(stoi(s
carpdm
NORMAL
2020-05-23T12:21:39.775727+00:00
2020-05-23T12:22:20.408073+00:00
135
false
```C++\nNestedInteger deserialize(string s) {\n \n if (s.size() == 0) return NestedInteger();\n if (s[0] != \'[\') return NestedInteger(stoi(s));\n NestedInteger res;\n // comma split\n int cnt = 0, last = 1;\n for (int i=1; i<s.size()-1; i++) {\n if (s[i] == ...
1
0
[]
0