Strategic guide to company-specific DSA preparation: Google's focus on graphs and DP, Meta's emphasis on arrays and trees, Amazon's leadership principles alignment with system design and BFS.
Search for a target in a matrix where each row and column is sorted. O(m+n) solution using top-right corner elimination — a classic Google interview problem.
Derive character ordering from a sorted alien dictionary using topological sort. Build a directed graph from adjacent word comparisons and apply Kahn's BFS algorithm.
Find the maximum in every sliding window of size k using a monotonic decreasing deque. O(n) solution that Google uses to test understanding of amortised data structures.
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.
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.
Count the number of inversions in an array (pairs where i < j but arr[i] > arr[j]) using modified merge sort in O(n log n). Google uses this to test deep algorithm understanding.
Find the k most frequent elements using a max-heap or bucket sort. O(n) bucket sort approach using frequency as bucket index — faster than O(n log n) heap.
Comprehensive coverage of Two Sum, Two Sum II (sorted), 3Sum, and 4Sum. Amazon frequently tests these variants to gauge understanding of hashmap vs two-pointer trade-offs.
Calculate how much water can be trapped in a 3D height matrix. Uses a min-heap BFS starting from the boundary, always processing the lowest border cell to determine water trapped inside.
Find the median of two sorted arrays in O(log(min(m,n))) time using binary search on partition points. A classic hard problem testing deep binary search understanding.
Create a deep copy of an undirected graph using DFS with a HashMap to track visited/cloned nodes. Meta tests this to evaluate graph traversal and pointer manipulation.
Complete recap of all 24 company-tagged problems with pattern classification, company attribution, and key insights. Use as a final review checklist before company-specific interviews.