LLinear·DSAEngineerTechnical Phone Screen
Flatten a Nested List Iterator
Problem
Implement an iterator over a nested list of integers supporting next() and hasNext().
Example
[[1,1],2,[1,1]] -> 1,1,2,1,1
Constraints
- Arbitrary nesting
Approach
Stack of iterators or flatten lazily. Reported Linear-style question.
added 6 days ago