https://leetcode.com/problems/flatten-nested-list-iterator



Success

___


yingshaoxo: I success not because I smart at the beginning, but because I'm the one who persistent at it the most.

___


```python
def go_through_list(list_):
    if type(list_) == NestedInteger:
        if list_._integer != None:
            return [list_._integer]

    all_ = []
    # print(list_)
    # print(type(list_))
    
    if type(list_) == list:
        pass
    elif type(list_) == NestedInteger:
        list_ = list_._list

    #print(list_)
    for one in list_:
        all_ += go_through_list(one)

    return all_

class NestedIterator:
    def __init__(self, nestedList: [NestedInteger]):
        #2023/01/27 09:49
        self.list = go_through_list(nestedList)
        self.length = len(self.list)
        self.index = 0
        #2023/01/27 9:57, debug until 10:05
    
    def next(self) -> int:
        value = self.list[self.index]
        self.index += 1
        return value
    
    def hasNext(self) -> bool:
        if self.index < self.length:
            return True
        else:
            return False
```
