Back to problems

Flatten Nested List Iterator

Object-Oriented Programming · Tesla · Easy

Problem: Flatten Nested List Iterator You receive nestedList, whose entries are either integers or lists containing more integers and nested lists. The nesting can continue to any depth. Build an iterator that exposes every integer in left-to-right traversal order. The iterator must provide these operations: next(): produces the next integer in the traversal. hasNext(): reports true when another integer remains and false when the iterator is exhausted. During the interview,…

Checking your access…