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–25
Given numCourses and prerequisite pairs, return any ordering of courses that satisfies all prerequisites or an empty array if impossible — this is essentially computing…
Companies: Amazon, Anduril, Apple, Citadel +11
Breadth-First Search · Depth-First Search · Graph Theory · Topological Sort
Last reported Nov 2026
Given a nested list of integers, compute the sum where each integer is weighted by the reverse of its depth (elements deeper in the nesting…
Companies: LinkedIn, Meta
Breadth-First Search · Depth-First Search · Stack
Last reported Oct 2026
Given a functional directed graph (each node has at most one outgoing edge), return the length of the longest directed cycle or -1 if no…
Companies: Anduril
Breadth-First Search · Depth-First Search · Graph Theory · Kosaraju's Algorithm
Last reported Oct 2026
Find the minimum-cost route from src to dst in a directed weighted graph with the constraint of at most k stops (i.e., a bound on…
Companies: Flipkart, Illumio, Meta, Oracle +1
Breadth-First Search · Depth-First Search · Dynamic Programming · Graph Theory
Last reported Oct 2026
Given coin denominations available in unlimited quantity and a target amount, find the minimum number of coins needed to form that amount (return -1 if…
Companies: Amazon, Google, Pinterest, Uber
Array · Breadth-First Search · Complete Knapsack · Dynamic Programming
Last reported Oct 2026
Given courses as nodes and prerequisite pairs as directed edges, determine whether the directed graph is acyclic — return true if a topological ordering exists…
Companies: Amazon, Anduril, Cloudflare, DoorDash +6
Breadth-First Search · Depth-First Search · Directed Acyclic Graph · Graph Theory
Last reported Oct 2026
Starting from given initial boxes, repeatedly open any box that is either already open or for which you have a key to collect its candies…
Companies: Airbnb
Array · Breadth-First Search · Graph Theory
Last reported Sep 2026
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
Given repeating bus routes and start/target stops, find the minimum number of bus rides required to go from source to target (or -1 if impossible)…
Companies: Amazon, Bloomberg, Coupang, PayPal +3
Array · Breadth-First Search · Hash Table
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 a sorted list of words in an unknown alphabet, infer the relative ordering of characters by deriving precedence constraints between first differing letters, then…
Companies: Amazon, Bloomberg, Google, Intuit +3
Array · Breadth-First Search · Depth-First Search · Directed Acyclic Graph
Last reported Aug 2026
Given a grid with buildings (1), empty land (0), and obstacles (2), find an empty cell that minimizes the sum of shortest (Manhattan) path distances…
Companies: Amazon, Coupang, DoorDash, Goldman Sachs +2
Array · Breadth-First Search · Matrix
Last reported Aug 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 an m×n grid with empty cells, fresh (1) and rotten (2) oranges, compute the minimum minutes until all fresh oranges become rotten as rot…
Companies: Amazon, Anduril, Flipkart, Goldman Sachs +3
Array · Breadth-First Search · Matrix
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 minimum number of steps from the top-left to bottom-right in a 4-directional binary grid if you may remove up to k obstacles; treat…
Companies: Amazon, Cisco, D. E. Shaw, Databricks +2
Array · Breadth-First Search · Matrix
Last reported Jul 2026
Given the root of a binary tree, return its maximum depth — the number of nodes along the longest root-to-leaf path. This classic easy problem…
Companies: Google, LinkedIn
Binary Tree · Breadth-First Search · Depth-First Search · Tree
Last reported Jun 2026
Given a directed graph whose underlying undirected graph is a tree, compute for every node the minimum number of edge reversals required so that starting…
Companies: Microsoft, Salesforce, Uber
Breadth-First Search · Depth-First Search · Dynamic Programming · Graph Theory
Last reported Jun 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
Simulate a Minesweeper click on an m×n board: clicking a mine turns it to 'X', while clicking an empty square requires counting adjacent mines —…
Companies: Meta, Microsoft, Nuro, Uber
Array · Breadth-First Search · Depth-First Search · Matrix
Last reported Jun 2026
Find the length of the shortest transformation sequence from beginWord to endWord where each step changes exactly one letter and every intermediate word must be…
Companies: Amazon, Apple, Fan, Meta +5
Bidirectional Search · Breadth-First Search · Hash Table · String
Last reported May 2026
Given a grid with grass, fire, and impassable walls, determine the maximum minutes you can wait at (0,0) before starting to move so that you…
Companies: Google, Uber
Array · Binary Search · Breadth-First Search · Matrix
Last reported May 2026
Given target coordinates (x, y), find the minimum number of knight moves required to reach that square from (0,0) on an infinite chessboard. This is…
Companies: eBay, Google, LinkedIn, Meta +1
A* Search · Bidirectional Search · Breadth-First Search · Heuristic Search
Last reported May 2026
Given a directed, nonnegative-weighted graph and a start node k, compute single-source shortest-path distances and return the maximum distance (the time for the signal to…
Companies: CrowdStrike, NVIDIA
Breadth-First Search · Depth-First Search · Dijkstra's Algorithm · Graph Theory
Last reported Apr 2026