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
Companies: Amazon, Apple, Meta
Binary Lifting · Binary Tree · Hash Table · Lowest Common Ancestor
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
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
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 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
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
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 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
Given an n×n binary grid (n a power of two), recursively build a quadtree by subdividing the grid into four equal quadrants until each region…
Companies: Snowflake, Uber
Array · Divide and Conquer · Matrix · Tree
Last reported May 2026
Maintain an evolving rooted family tree (king as root) that supports adding a child and marking a person dead, and return the current inheritance order…
Companies: Apple, Snowflake
Depth-First Search · Design · Hash Table · Tree
Last reported May 2026
Given a binary tree and the node x chosen by player 1, determine whether player 2 can pick a node y that guarantees victory by…
Companies: Anduril
Binary Tree · Depth-First Search · Tree
Last reported May 2026
Find all root-to-leaf paths in a binary tree whose node values sum to targetSum, returning each path as a list of values. This is solved…
Companies: Amazon, Meta, Microsoft, Salesforce
Backtracking · Binary Tree · Depth-First Search · Tree
Last reported May 2026
Given lists where each entry names a parent region followed by its immediate subregions and two region names, find their smallest common region — the…
Companies: Airbnb
Array · Binary Lifting · Breadth-First Search · Depth-First Search
Last reported Apr 2026
Design algorithms to serialize an N-ary tree into a single string and deserialize it back, preserving node values and the arbitrary number and order of…
Companies: Apple, Bloomberg, Rubrik, TikTok
Breadth-First Search · Depth-First Search · String · Tree
Last reported Mar 2026
Given a binary tree and a target node value, return all node values at distance K from the target. The challenge is to traverse both…
Companies: Amazon, Meta, Microsoft, TikTok
Binary Tree · Breadth-First Search · Depth-First Search · Hash Table
Last reported Mar 2026
Return the boundary of a binary tree: list nodes on the left boundary top-down (excluding leaves), then all leaves left-to-right, then the right boundary bottom-up…
Companies: Amazon, Meta, Snowflake
Binary Tree · Depth-First Search · Tree
Last reported Feb 2026
For each node c in a weighted tree, count unordered pairs of distinct servers (a,b) (neither equal to c) such that the distances from c…
Companies: NVIDIA, Rippling
Array · Depth-First Search · Tree
Last reported Dec 2025
Given a binary tree and a start node, compute how many minutes it takes for an infection that spreads each minute to adjacent nodes (parent/children)…
Companies: Microsoft, Salesforce
Binary Tree · Breadth-First Search · Depth-First Search · Hash Table
Last reported Dec 2025
Count the nodes in a binary tree whose value equals the integer average (floor of sum/count) of all values in their subtree — solved by…
Companies: Meta, Snowflake
Binary Tree · Depth-First Search · Tree
Last reported Aug 2025
Return the node values of a binary tree in inorder (left → root → right) sequence. The recursive solution is trivial; the follow-up asks for…
Companies: Anduril, Meta, Oracle
Binary Tree · Depth-First Search · Stack · Tree
Last reported Jul 2025
Return the k-th smallest value (1-indexed) in a BST — exploit that an in-order traversal yields values in sorted order and pick the k-th visited…
Companies: Amazon, Google, Meta, Uber
Binary Search Tree · Binary Tree · Depth-First Search · Tree
Last reported Mar 2025
Given a BST root and a value not already present, insert the value as a new leaf in the correct position to preserve BST ordering…
Companies: Anduril, LinkedIn
Binary Search Tree · Binary Tree · Tree
Last reported Feb 2025
Check whether a binary tree is height-balanced, i.e., for every node the heights of its left and right subtrees differ by at most one. With…
Companies: Anduril
Binary Tree · Depth-First Search · Tree