[LeetCode][Python] 341. Flatten Nested List Iterator
2019. 3. 22. 01:39 |
프로그래밍/LeetCode
Problem :
https://leetcode.com/problems/flatten-nested-list-iterator/
My Solution :
class NestedIterator(object):
def __init__(self, nestedList):
def generator(nestedList):
for item in nestedList:
if item.isInteger():
yield item.getInteger()
else:
for yielded in generator(item.getList()):
yield yielded
self.generator = generator(nestedList)
def next(self):
return self.value
def hasNext(self):
self.value = next(self.generator, None)
return self.value is not None
'프로그래밍 > LeetCode' 카테고리의 다른 글
[LeetCode][Python3] 105. Construct Binary Tree from Preorder and Inorder Traversal (0) | 2019.03.24 |
---|---|
[LeetCode][Python3] 131. Palindrome Partitioning (0) | 2019.03.23 |
[LeetCode][Python3] 128. Longest Consecutive Sequence (0) | 2019.03.23 |
[LeetCode][Python3] 42. Trapping Rain Water (0) | 2019.03.23 |
[LeetCode][Python3] 200. Number of Islands (0) | 2019.02.11 |
[LeetCode][Python3] 300. Longest Increasing Subsequence (0) | 2019.02.10 |
[LeetCode][Python3] 240. Search a 2D Matrix II (0) | 2019.02.09 |
[LeetCode][Python3] 103. Binary Tree Zigzag Level Order Traversal (0) | 2019.02.07 |
최근에 달린 댓글 최근에 달린 댓글