DSA Tracker

Topic

Graph interview questions

All 48 Graph problems from the curated set, easiest first — a core topic for 11 of the 29 engineering roles.

Easy
1
Medium
36
Hard
11
Sheets
3
Watch the Graph pattern solved step by step

What Graph is

Updated 2026-09-09

A graph is a network of individual points, called vertices or nodes, connected by lines called edges. Think of a subway transit map, an electrical circuit, or a web of social friends. Unlike a tree, a graph has no designated top node and no parent-child hierarchy. Connections can run one-way or both ways, and paths can loop back on themselves to form closed cycles.

When to reach for it

Reach for graph algorithms when inputs describe relationships, networks, flights between cities, course prerequisites, or clone networks. Signals include finding the shortest route across unweighted connections, ordering tasks that depend on earlier tasks, counting isolated clusters, or checking whether a path contains an infinite loop. Whenever problems present pairs of related entities and ask for reachability, distances, or dependencies, graph representations apply.

How to think about it

First convert edge lists into an adjacency list, mapping each node to an array of its neighbors. Choose your exploration strategy based on the goal: use a queue and breadth-first search to find the shortest path in unweighted networks, or use recursion and depth-first search to explore full paths and detect cycles. Because graphs can have loops, always track visited nodes in a set or boolean array. Add nodes to the visited set at the moment they enter the queue so they are never visited twice.

What each operation costs

OperationTime
visit all nodes and edges via searchO(v + e)
topological sort using in-degree countsO(v + e)
shortest path using dijkstra with a min-heapO((v + e) log v)
What usually goes wrong
  • Adding a node to the visited set when popping from the queue instead of when pushing, which lets neighboring nodes enqueue duplicate entries and wastes memory.
  • Failing to check for cycles in directed graphs when finding prerequisite orders, causing topological sort routines to hang or return incomplete lists.
  • Assuming an input graph is fully connected and scanning from only a single starting node, missing disconnected islands and isolated components.

Every Graph problem, easiest first

Roles that need Graph

If you are targeting one of these, Graph sits early in your path rather than being optional.

Track Graph in your role's order

Pick your target role and all 370 problems resequence to what that interview actually asks. Free.

Start free

Graph interview questions, answered

How many Graph problems should I solve for interviews?

48 curated Graph problems cover the patterns interviews repeat: 1 easy, 36 medium and 11 hard. They are drawn from 3 widely used sheets, deduplicated, and ordered easiest first.

Is Graph actually asked in coding interviews?

Yes, though how much depends on the role. Graph is a core topic for 11 of the 29 engineering roles tracked here, including SDE / Backend Engineer, Data Engineer, Game Developer. For other roles it is lower frequency and belongs later in a study plan.

Which Graph problem should I start with?

Start with Flood Fill (Easy). The list on this page is ordered easiest first for that reason, so working top to bottom builds the pattern before the harder variations arrive.

Other topics

Problem set and role mapping as of .