Iterator
LeetCode 173: Binary Search Tree Iterator
·2 mins
LeetCode
Medium
Stack
Tree
Design
Binary-Search-Tree
Binary-Tree
Iterator
LeetCode 173 note: flattening to an array is simple but uses O(n) space; the follow-up keeps the left spine on a stack for amortized O(1) and O(h) space
Queue and Design Problems
·3 mins
Algorithm
Queue
Design
Iterator
Lazy-Deletion
Circular queues, zigzag iterators, FIFO matching with cancellation, and the data structure combinations that design problems keep using
LeetCode 281: Zigzag Iterator
·2 mins
LeetCode
Medium
Queue
Design
Iterator
LeetCode 281 note: a queue of unfinished sources, take one value in turn and put the source back if anything remains; it generalizes to k sources