# """# This is the interface that allows for creating nested lists.# You should not implement it, or speculate about its implementation# """#class NestedInteger(object):# def isInteger(self):# """# @return True if this NestedInteger holds a single integer, rather than a nested list.# :rtype bool# """## def getInteger(self):# """# @return the single integer that this NestedInteger holds, if it holds a single integer# Return None if this NestedInteger holds a nested list# :rtype int# """## def getList(self):# """# @return the nested list that this NestedInteger holds, if it holds a nested list# Return None if this NestedInteger holds a single integer# :rtype List[NestedInteger]# """classNestedIterator(object):def__init__(self,nestedList):""" Initialize your data structure here. :type nestedList: List[NestedInteger] """self.array=[]deffill(nl):forniinnl:# 找到一个integerifni.isInteger():self.array.append(ni.getInteger())else:# 找到一个List[NestedInteger]fill(ni.getList())fill(nestedList)self.index=0defnext(self):""" :rtype: int """i=self.indexself.index+=1returnself.array[i]defhasNext(self):""" :rtype: bool """returnself.index<len(self.array)