Pattern · Graph

Graph interview questions

91 graph problems tagged across recent interview reports. Drilled most heavily by citadel, uber, and snowflake.

Founder's read

Graph problems form the backbone of interview loops at trading firms, ride-sharing platforms, and data infrastructure companies. With 91 variants in the wild, you'll see graphs tested across traversal, shortest path, cycle detection, and topological sort. Citadel, Uber, and Snowflake lean hard on graph patterns. If you hit an unfamiliar variant during your live assessment, StealthCoder reads the problem and delivers the solution invisible to the proctor.

Most-asked graph problems

#ProblemDiff# Companies
01Course ScheduleMEDIUM34
02Course Schedule IIMEDIUM33
03Evaluate DivisionMEDIUM17
04Clone GraphMEDIUM14
05Alien DictionaryHARD13
06Cheapest Flights Within K StopsMEDIUM9
07Longest Increasing Path in a MatrixHARD8
08Find the CelebrityMEDIUM7
09Design Excel Sum FormulaHARD5
10Find All Possible Recipes from Given SuppliesMEDIUM5
11Graph Valid TreeMEDIUM5
12Keys and RoomsMEDIUM5
13Min Cost to Connect All PointsMEDIUM5
14Collect Coins in a TreeHARD3
15Detonate the Maximum BombsMEDIUM3
16Longest Path With Different Adjacent CharactersHARD3
17Maximum Path Quality of a GraphHARD3
18Minimize Malware SpreadHARD3
19Design Graph With Shortest Path CalculatorHARD2
20Find the Town JudgeEASY2
21Is Graph Bipartite?MEDIUM2
22Largest Color Value in a Directed GraphHARD2
23Maximal Network RankMEDIUM2
24Maximum Candies You Can Get from BoxesHARD2
25Maximum Employees to Be Invited to a MeetingHARD2
26Maximum XOR of Two Non-Overlapping SubtreesHARD2
27Add Edges to Make Degrees of All Nodes EvenHARD1
28All Ancestors of a Node in a Directed Acyclic GraphMEDIUM1
29All Paths From Source to TargetMEDIUM1
30Apply SubstitutionsMEDIUM1
31Count Unreachable Pairs of Nodes in an Undirected GraphMEDIUM1
32Count Visited Nodes in a Directed GraphHARD1
33Couples Holding HandsHARD1
34Critical Connections in a NetworkHARD1
35Distance to a Cycle in Undirected GraphHARD1
36Divide Nodes Into the Maximum Number of GroupsHARD1
37Find Closest Node to Given Two NodesMEDIUM1
38Find Edges in Shortest PathsHARD1
39Find Eventual Safe StatesMEDIUM1
40Find Minimum Diameter After Merging Two TreesHARD1
41Find the City With the Smallest Number of Neighbors at a Threshold DistanceMEDIUM1
42Flower Planting With No AdjacentMEDIUM1
43Frequencies of Shortest SupersequencesHARD1
44Get Watched Videos by Your FriendsMEDIUM1
45Longest Cycle in a GraphHARD1
46Loud and RichMEDIUM1
47Maximize Amount After Two Days of ConversionsMEDIUM1
48Maximum Star Sum of a GraphMEDIUM1
49Maximum Total Importance of RoadsMEDIUM1
50Minimize Malware Spread IIHARD1

Showing top 50 of 91 graph problems by # companies asking.

The hedge for the live OA

You can't drill every graph variant before the assessment. StealthCoder runs invisibly during screen share and solves whichever variant they throw at you. No browser extension. No detection signature. Made by a working FAANG engineer who treats the OA the way companies treat hiring: as a game with rules you should know.

Get StealthCoder
What this means

Graph problems hide inside real business logic: route optimization (Uber), recommendation chains (TikTok), dependency resolution (Snowflake). The pattern emerges when you model relationships as nodes and edges, then solve for connectivity, cost, or ordering. You'll recognize it fast: the problem describes objects and relationships between them. Subtypes include BFS/DFS (clone-graph, count-visited-nodes-in-a-directed-graph), shortest path (cheapest-flights-within-k-stops), topological sort (alien-dictionary, course-schedule), and tree variants (all-paths-from-source-to-target). Drill traversal and cycle detection first, then optimization. On test day, when a hard graph variant lands and you're mid-assessment, StealthCoder is the safety net that gets you unstuck and moving.

Companies that hire most on graph

The honest play

91 graph problems. You won't drill them all. Pass anyway.

Graph is one of the patterns interviews actually filter on. Memorizing every variant in a week is a fantasy. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds, no matter which graph flavor lands in your live OA. Made by a working FAANG engineer who treats the OA the way companies treat hiring: as a game with rules you should know. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Graph interview FAQ

How many graph problems should I drill before interviews?+

Start with 12-15 core problems covering DFS, BFS, and topological sort. The sample set (clone-graph, course-schedule, all-paths-from-source-to-target) is solid. Then drill 20-30 more covering weighted graphs and cycle detection. 91 total problems exist; you don't need all of them, but pattern recognition matters more than count.

Which company drills graph patterns the hardest?+

Citadel (24 problems) and Uber (22) are the heaviest. Snowflake, DoorDash, Snap, and TikTok each have 20 or more. If you're interviewing at any of these, graph is non-negotiable. Expect 1-2 graph problems in your loop.

How do I spot a graph problem in the wild?+

Look for language like 'nodes', 'connections', 'paths', 'dependencies', 'relationships', or 'routes'. If the problem asks you to model entities and their links, then traverse, order, or optimize, it's a graph. Problems like alien-dictionary or course-schedule disguise themselves as strings or arrays until you map the structure.

What's the difference between DFS and BFS on graphs?+

DFS uses a stack (recursion) and goes deep first; BFS uses a queue and explores layer by layer. Use DFS for topological sort and cycle detection. Use BFS for shortest path in unweighted graphs and level-order traversal. Both are O(V + E). Pick based on what the problem asks you to find.

Should I memorize graph solutions or understand the pattern?+

Understand the pattern. Once you recognize BFS, DFS, or Dijkstra, the solution logic follows. Memorize the data structure setup (adjacency list, visited set) and the loop skeleton, not the code. That way, when you see a variant you haven't drilled, you can adapt fast. Pattern beats memorization.

Problem and frequency data sourced from public community-maintained interview-report repos. Problems and trademarks © LeetCode.