File tree Expand file tree Collapse file tree 1 file changed +49
-0
lines changed
src2/FlattenNestedListIterator Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change 1+ # """
2+ # This is the interface that allows for creating nested lists.
3+ # You should not implement it, or speculate about its implementation
4+ # """
5+ #class NestedInteger(object):
6+ # def isInteger(self):
7+ # """
8+ # @return True if this NestedInteger holds a single integer, rather than a nested list.
9+ # :rtype bool
10+ # """
11+ #
12+ # def getInteger(self):
13+ # """
14+ # @return the single integer that this NestedInteger holds, if it holds a single integer
15+ # Return None if this NestedInteger holds a nested list
16+ # :rtype int
17+ # """
18+ #
19+ # def getList(self):
20+ # """
21+ # @return the nested list that this NestedInteger holds, if it holds a nested list
22+ # Return None if this NestedInteger holds a single integer
23+ # :rtype List[NestedInteger]
24+ # """
25+
26+ class NestedIterator (object ):
27+
28+ def __init__ (self , nestedList ):
29+ """
30+ Initialize your data structure here.
31+ :type nestedList: List[NestedInteger]
32+ """
33+
34+
35+ def next (self ):
36+ """
37+ :rtype: int
38+ """
39+
40+
41+ def hasNext (self ):
42+ """
43+ :rtype: bool
44+ """
45+
46+
47+ # Your NestedIterator object will be instantiated and called as such:
48+ # i, v = NestedIterator(nestedList), []
49+ # while i.hasNext(): v.append(i.next())
You can’t perform that action at this time.
0 commit comments