Meta — Flatten Nested List Iterator (Stack-Based)
Implement an iterator for a nested list that flattens it lazily. Meta favors this for testing iterator design, stack usage, and lazy evaluation.
webcoderspeed.com
1276 articles
Implement an iterator for a nested list that flattens it lazily. Meta favors this for testing iterator design, stack usage, and lazy evaluation.
Serialize a binary tree to a string and deserialize it back. Meta loves this problem for testing tree traversal and string parsing. Both BFS and preorder DFS approaches shown.
Implement a read() function using a read4() primitive. Two variants: read once and read multiple times. Tests buffer management and pointer arithmetic.
Count islands after each addLand operation using incremental Union-Find. Each new land cell potentially merges with up to 4 neighbors — classic Amazon system-at-scale problem.
Design a stream that always returns the kth largest element after each add. Uses a min-heap of size k — the top is always the kth largest.