Flatten a nested list iterator

0
Remix

A list holds integers and other lists, nested to any depth. Write an iterator with next() and has_next() that returns the integers in order. Do it lazily with a stack of positions rather than flattening everything up front, and make sure empty inner lists are skipped.

AirbnbCodingLast asked Apr 2026
No answer yet. Write the first one; the best answer gets endorsed.