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 list of directed flight tickets, reconstruct an itinerary starting at "JFK" that uses every ticket exactly once and, among all valid itineraries, returns…
Companies: Amazon, Anduril, Google, Pinterest
Array · Depth-First Search · Eulerian Circuit · Eulerian Path
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 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
Given a binary tree and two nodes p and q, find their lowest common ancestor (LCA) — the deepest node that has both p and…
Companies: Amazon, Apple, Atlassian, Canva +6
Binary Lifting · Binary Tree · Depth-First Search · Lowest Common Ancestor
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
Companies: Adobe, Amazon, Bloomberg, Microsoft
Depth-First Search · Doubly-Linked List · Linked List
Last reported Sep 2026
Given the root of a binary tree, return the diameter — the maximum number of edges on any path between two nodes; the core challenge…
Companies: Meta, Oracle, Roblox
Binary Tree · Depth-First Search · DP on Trees · Tree
Last reported Sep 2026
Given a BST, a real-valued target and an integer k, return the k node values in the tree closest to the target. The challenge is…
Companies: Amazon, LinkedIn
Binary Search Tree · Binary Tree · Depth-First Search · Heap (Priority Queue)
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 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
Place the minimum number of cameras on nodes of a binary tree so every node is monitored by a camera on itself, its parent, or…
Companies: Amazon, D. E. Shaw
Binary Tree · Depth-First Search · DP on Trees · Dynamic Programming
Last reported Aug 2026
Determine whether a binary tree is a valid binary search tree by checking that each node's value is strictly greater than all values in its…
Companies: Amazon, Lyft, Microsoft
Binary Search Tree · Binary Tree · Depth-First Search · Tree
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
Given a nested list where elements may be integers or sublists, implement a NestedIterator with next() and hasNext() that returns all integers in depth‑first, left‑to‑right…
Companies: Adobe, LinkedIn
Depth-First Search · Design · Iterator · Queue
Last reported Aug 2026
Determine whether a target word can be formed by a path of horizontally or vertically adjacent cells in an m×n letter grid without reusing a…
Companies: Amazon, Glean, Google, Grammarly +3
Array · Backtracking · Depth-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
Find the maximum sum of any non-empty connected path in a binary tree (nodes used at most once), where the path can start and end…
Companies: Amazon, Datadog, DoorDash, Expedia +4
Binary Tree · Depth-First Search · DP on Trees · Dynamic Programming
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
Given a Binary Search Tree and a target numeric value, return the value of the node in the tree that is closest to the target…
Companies: Expedia, Meta, Roblox
Binary Search · Binary Search Tree · Binary Tree · Depth-First Search
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