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.
- Number of Connected Components in an Undirected GraphMedium3 companies
- Maximum XOR of Two Non-Overlapping SubtreesHard2 companies
- Minimum Cost to Buy ApplesMedium2 companies
- Satisfiability of Equality EquationsMedium2 companies
- Count Visited Nodes in a Directed GraphHard1 company
- Detonate the Maximum BombsMedium1 company
- Minimum Cost to Make at Least One Valid Path in a GridHard1 company
- Minimum Time to Break Locks IIHard1 company
- Longest Cycle in a GraphHard1 company
- Reachable Nodes With RestrictionsMedium1 company
Study, Watch and Solve Graph Problems
Follow CodeStory's order to make graphs stick.
More to Practise Inside the App
CodeStory pairs patterns with interviews and career tools. Swipe for more.
Technique Drills
Drill one technique before you move to the next.
352 problemsOpenHiring Company Sets
Practise what a named company asks.
463 companiesOpenLive Coding Interview
Choose a role and code while questions arrive.
scored reportOpenVoice Interview Rounds
Speak your answers and meet follow ups.
32 topicsOpenDBMS Viva Prep
Face index, join and normalisation questions.
in Core CSOpenOOP Viva Prep
Defend your inheritance and polymorphism answers.
in Core CSOpenSystem Design Chapters
Study how systems get built, layer by layer.
27 chaptersOpenSQL Challenges
Query real tables and check every row.
39 questionsOpenAptitude Tests
Quant, logic, verbal and DI under a timer.
280 questionsOpenTimed Coding Assessments
Practise with marks and hidden tests.
37 papersOpenAlgorithm Animations
Follow every step on input you choose.
26 algorithmsOpenGuided AI Hints
Reveal hints gradually before you ask for review.
100 free creditsOpenResume Maker
Build your resume beside your practice record.
in the appOpenReadiness Score
See one score and your weakest area.
tracked dailyOpen
Sign up to collect 100 AI credits, then 100 more monthly. Start free in the app
Graph Problems FAQs
Start free with no card, or ask a mentor on a free call.
Start Practising GraphHow 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.
- 1CodeStory grades your level, from first graph to interview ready.
- 2CodeStory shares online and campus batches, with timings that suit your routine.
- 3You decide. No pressure, no payment on the call.