Interview questions
Find a company or topic. Read the sources, then practice.
Loading the question library…
Find a company or topic. Read the sources, then practice.
Loading the question library…
Showing 1–15
Count the number of islands (4-directionally connected components of '1's) in an m×n binary grid. This is a connected-components/flood-fill problem typically solved with…
Companies: Amazon, Anduril, Apple, ByteDance +16
Array · Breadth-First Search · Depth-First Search · Matrix
Last reported Sep 2026
For each query threshold, compute how many distinct cells you can reach from the top-left by moving 4-directionally through cells whose value is strictly less…
Companies: Uber
Array · Breadth-First Search · Heap (Priority Queue) · Matrix
Last reported Sep 2026
Given pairwise variable ratios, build a weighted graph (or use union-find with multiplicative weights) where edges represent divisions, and answer each query by finding a…
Companies: Amazon, Bloomberg
Array · Bellman–Ford Algorithm · Breadth-First Search · Depth-First Search
Last reported Sep 2026
Given an initially all-water m×n grid, process a sequence of add-land operations and return the number of islands (4-directionally connected land components) after each…
Companies: LinkedIn, Microsoft, Uber
Array · Hash Table · Union-Find
Last reported Sep 2026
Given an n x n symmetric adjacency matrix where isConnected[i][j]=1 denotes a direct undirected edge between cities, count the number of connected components (provinces) formed…
Companies: Amazon, Coupang, Uber
Breadth-First Search · Depth-First Search · Graph Theory · Union-Find
Last reported Aug 2026
Given timestamped friendship events among N people, determine the earliest time when the social graph becomes fully connected; process events in chronological order and use…
Companies: Amazon, Google, Uber
Array · Sorting · Union-Find
Last reported Aug 2026
Given lists of accounts where each account has a name and emails, merge accounts that share any email by grouping connected emails (e.g., via union-find…
Companies: Airbnb, Bloomberg, Meta, Oracle +1
Array · Breadth-First Search · Depth-First Search · Hash Table
Last reported Aug 2026
Find the length of the longest run of consecutive integers in an unsorted array, with an O(n) time requirement. The core idea is to detect…
Companies: Amazon, Bloomberg, Google, Microsoft +1
Array · Hash Table · Union-Find
Last reported Aug 2026
Given a binary grid, count how many distinct island shapes (connected components of 1s via 4-directional adjacency) appear, treating two islands as identical if they…
Companies: Anduril, Oracle, TikTok
Array · Breadth-First Search · Depth-First Search · Hash Function
Last reported Jun 2026
Given an n×n binary grid where you can flip at most one 0 to 1, compute the largest possible 4-directional island size after the flip…
Companies: DoorDash, Meta, TikTok, Uber
Array · Breadth-First Search · Depth-First Search · Matrix
Last reported Mar 2026
Given n people and pairwise dislikes, determine whether the corresponding undirected graph is bipartite — i.e., whether you can 2-color all vertices (split into two…
Companies: LinkedIn, TikTok, Uber
Bipartite Graph · Breadth-First Search · Depth-First Search · Graph Coloring
Last reported Dec 2025
Compute each cell's Manhattan distance to the nearest thief, then find a path from (0,0) to (n-1,n-1) that maximizes the minimum of those distances along…
Companies: Google, Meta, Uber
Array · Binary Search · Breadth-First Search · Heap (Priority Queue)
Last reported May 2025
Given a string and allowed index swap pairs, view pairs as edges in a graph to find connected components where characters can be freely permuted…
Companies: Goldman Sachs, Google
Array · Breadth-First Search · Depth-First Search · Hash Table
Last reported Oct 2024
You may swap two indices iff their values differ by at most limit; compute the lexicographically smallest array obtainable by any sequence of such swaps…
Companies: Goldman Sachs, Uber
Array · Sorting · Union-Find
Given an undirected graph and a set of initially infected nodes, choose one initial node to remove so that the eventual malware spread across connected…
Companies: Zomato
Array · Breadth-First Search · Depth-First Search · Graph Theory