Design an iterator to flatten a nested list of integers. NestedInteger is either an int or a list of NestedInteger. Use a stack; ensure the top is always an integer before next.
nextO(1)amortized
hasNextO(1)amortized
SpaceO(d)nesting depth
Step0
stack: …
Ready
Press Play or Step.
✎ Whiteboard
3
⌨ Type It
Practice until you don't need to look. Green highlights are the nuances to burn into memory.