Skip to content

Graph Problems
and How to Spot Them

CodeStory tags 85 problems as Graph, and 45 of them are Medium. Build the adjacency list first, then solve the ten most asked.

Signing up costs nothing and brings 100 AI credits, then 100 more monthly.

How the Graph Pattern Works

CodeStory covers the tell, the adjacency list mechanism and the wrong graph mistake.

Spot the tell. Your problem connects things to other things, and the question asks about reachability, order or distance. Study CodeStory's Graph guide before you code.

Learn the mechanism. Build an adjacency list first, then choose the walk. Use BFS for fewest steps, DFS for full components, Dijkstra for weights and topological sort for dependencies. Practise the walks in CodeStory's breadth first search problems and depth first search problems.

Avoid the mistake. Building the graph wrong costs the most. Directing an edge one way when it should go both ways, or missing the reverse edge, feeds a correct algorithm the wrong input.

Most Asked Graph Problems

CodeStory ranks these by company count, and connected components lead.

  1. Number of Connected Components in an Undirected GraphMedium3 companies
  2. Maximum XOR of Two Non-Overlapping SubtreesHard2 companies
  3. Minimum Cost to Buy ApplesMedium2 companies
  4. Satisfiability of Equality EquationsMedium2 companies
  5. Count Visited Nodes in a Directed GraphHard1 company
  6. Detonate the Maximum BombsMedium1 company
  7. Minimum Cost to Make at Least One Valid Path in a GridHard1 company
  8. Minimum Time to Break Locks IIHard1 company
  9. Longest Cycle in a GraphHard1 company
  10. Reachable Nodes With RestrictionsMedium1 company

Study, Watch and Solve Graph Problems

Follow CodeStory's order to make graphs stick.

Graph Problems FAQs

Start free with no card, or ask a mentor on a free call.

Start Practising Graph
How do I know a problem is a Graph problem?

CodeStory looks for one sign. Your problem connects things to other things, and the question asks about reachability, order or distance.

How many Graph problems should I solve?

CodeStory suggests ten to fifteen across the levels, which is enough to stop needing the hint. CodeStory shows all 85 tagged problems, split 1 Easy, 45 Medium and 39 Hard, so expect almost no Easy ones.

Which mistake costs the most in Graph problems?

Building the graph wrong costs the most. Directing an edge one way when it should go both ways, or missing the reverse edge, feeds a correct algorithm the wrong input.

Which algorithm should I use for a Graph problem?

Use BFS for fewest steps, DFS for full components, Dijkstra for weights and topological sort for dependencies. Build the adjacency list first, whichever you choose.

Is practising by pattern better than a problem sheet?

Yes. Sheets give you problems in a row, while CodeStory's patterns show how they connect, and that carries over to problems you have not seen. CodeStory files every problem under its pattern.

Which Graph problems do companies ask most?

Number of Connected Components in an Undirected Graph leads, asked at 3 companies in CodeStory's catalogue. Three more problems follow at 2 companies.

Is Graph practice free to start?

Yes. CodeStory needs no card, gives you 100 AI credits at signup and adds 100 more every month.

Want Guided Graph Practice? Get a Free Callback

Tell CodeStory your goal, and a mentor outlines your route.

  1. 1CodeStory grades your level, from first graph to interview ready.
  2. 2CodeStory shares online and campus batches, with timings that suit your routine.
  3. 3You decide. No pressure, no payment on the call.

Get a Free Callback

I am a
I want to learn

CodeStory dials your number only for this callback.