← 返回 google 的题目列表Binary Tree Level Order Stream Iterator
类型:online_judge
Implement a stream iterator that returns the level order traversal results of a binary tree by levels. The whole tree structure does not need to be traversed at once. The iterator interface contains next() and hasNext() methods. next() returns a list of node values for one entire level each time, while hasNext() returns True if there are more levels to traverse, otherwise False. Focus on single-step time complexity and space efficiency. Follow-up: How can the integrity and performance be ensured when multiple iterators share the same tree structure?
Example
Input
['BinaryTreeNode object as root']