Mock technical interviews with an AI interviewer.
Every problem leaves something out. Ask about it before you code.
Problems
- Breadth-First Visit OrderThere are n nodes numbered 0 to n - 1 and a list of connections between pairs of nodes. Return the order in which a breadth-first search starting at the start node visits the nodes it can reach.EasyGraphsGraphs
- Busiest NodeThere are n nodes numbered 0 to n - 1 and a list of connections, each a pair of nodes. Return the node that has the most connections.EasyGraphsGraphs
- Edge List to Adjacency ListsA graph has n nodes numbered 0 to n - 1 and a list of connections, each a pair of nodes joined both ways. Return its adjacency lists: for each node, in order, the list of its neighbors in increasing order.EasyGraphsGraphs
- Edge List to Adjacency MatrixA graph has n nodes numbered 0 to n - 1 and a list of edges, each written [u, v, w]. Return its adjacency matrix: an n by n grid with one cell for each ordered pair of nodes (row u, column v), and 0 where there is no edge.EasyGraphsGraphs
- Hub of a NetworkOne hub node is joined directly to every other node, and there are no other connections. Given the connections, each a pair of nodes, return the hub.EasyGraphsGraphs
- Is It a Simple GraphA graph has n nodes numbered 0 to n - 1 and a list of edges, each a pair of nodes. A simple graph has no edge from a node to itself and no edge listed twice. Return whether this graph is simple.EasyGraphsGraphs
- Is It a Valid PathA graph has n nodes numbered 0 to n - 1 and a list of connections. Given a sequence of nodes, return whether it is a valid path through the graph: each node in the sequence must be connected to the next one.EasyGraphsGraphs
- Is There a RouteThere are n nodes numbered 0 to n - 1 and a list of connections, each a pair of nodes. Decide whether the target node can be reached from the source node by following connections.EasyGraphsGraphs
- Separate NetworksA company has n computers numbered 0 to n - 1, and a list of cables, each joining two computers. Computers that can reach each other through cables are on the same network. How many separate networks are there?EasyGraphsGraphs
- The Person Everyone TrustsAmong n people numbered 1 to n, you get pairs [a, b] meaning a trusts b. Return the number of the person whom all the others trust and who trusts no one, or -1 if nobody fits.EasyGraphsGraphs
- Count Land PatchesYou are given a grid of 0s and 1s, where 1 is land and 0 is water. Return how many separate patches of land the grid contains.MediumGraphsGraphs
- Depth-First Visit OrderThere are n nodes numbered 0 to n - 1, joined by two-way connections. Return the order in which a depth-first search from the start node visits the nodes: it always goes as deep as it can before backing up.MediumGraphsGraphs
- Distance to the Nearest MineA grid has open cells (0), walls (1) and mines (2). For every cell, return the fewest steps from it to the nearest mine, moving between open cells. A mine is 0 steps from a mine.MediumGraphsGraphs
- Fewest Steps Through a MazeA maze is a grid in which 0 is an open cell and 1 is a wall. Starting at the top-left cell, find the fewest steps needed to reach the bottom-right cell.MediumGraphsGraphs
- Finish Every TaskThere are n tasks numbered 0 to n - 1. Some tasks must be finished before others, given as a list of pairs [a, b], meaning a must be finished before b. Can all the tasks be finished?MediumGraphsGraphs
- Morphing One Word Into AnotherTurn the begin word into the end word by changing one letter at a time; each word along the way must come from the given list. Return the fewest changes needed.HardGraphsGraphs