Meta — Serialize and Deserialize Binary Tree (BFS/Preorder)
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.
1575 articles
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.
Find the minimum intervals to complete all tasks given cooldown n. Greedy with max-heap: always execute most frequent available task, idle only when forced.