# Graph Theory DSA Problems

> 162 Graph Theory coding problems for placements and interviews, sorted easiest first, with hints and company tags. Free practice on InternHack.

Canonical: https://www.internhack.in/learn/dsa/graph-theory
Last updated: 2026-11-28

162 graph theory problems for coding interviews and campus placements, with hints and company tags. Below are the first 100 of 162: 3 easy, 18 medium and 79 hard. Practise them free on InternHack and track what you have solved.

## Graph Theory problems, easiest first

1. [Find Center of Star Graph](https://www.internhack.in/learn/dsa/problem/find-center-of-star-graph) (Easy)
2. [Find if Path Exists in Graph](https://www.internhack.in/learn/dsa/problem/find-if-path-exists-in-graph) (Easy)
3. [Find the Town Judge](https://www.internhack.in/learn/dsa/problem/find-the-town-judge) (Easy)
4. [All Ancestors of a Node in a Directed Acyclic Graph](https://www.internhack.in/learn/dsa/problem/all-ancestors-of-a-node-in-a-directed-acyclic-graph) (Medium)
5. [All Paths from Source Lead to Destination](https://www.internhack.in/learn/dsa/problem/all-paths-from-source-lead-to-destination) (Medium)
6. [All Paths From Source to Target](https://www.internhack.in/learn/dsa/problem/all-paths-from-source-to-target) (Medium)
7. [Apply Substitutions](https://www.internhack.in/learn/dsa/problem/apply-substitutions) (Medium)
8. [Cheapest Flights Within K Stops](https://www.internhack.in/learn/dsa/problem/cheapest-flights-within-k-stops) (Medium)
9. [Clone Graph](https://www.internhack.in/learn/dsa/problem/clone-graph) (Medium)
10. [Connecting Cities With Minimum Cost](https://www.internhack.in/learn/dsa/problem/connecting-cities-with-minimum-cost) (Medium)
11. [Count the Number of Complete Components](https://www.internhack.in/learn/dsa/problem/count-the-number-of-complete-components) (Medium)
12. [Count the Number of Houses at a Certain Distance I](https://www.internhack.in/learn/dsa/problem/count-the-number-of-houses-at-a-certain-distance-i) (Medium)
13. [Count Unreachable Pairs of Nodes in an Undirected Graph](https://www.internhack.in/learn/dsa/problem/count-unreachable-pairs-of-nodes-in-an-undirected-graph) (Medium)
14. [Course Schedule](https://www.internhack.in/learn/dsa/problem/course-schedule) (Medium)
15. [Course Schedule II](https://www.internhack.in/learn/dsa/problem/course-schedule-ii) (Medium)
16. [Course Schedule IV](https://www.internhack.in/learn/dsa/problem/course-schedule-iv) (Medium)
17. [Detonate the Maximum Bombs](https://www.internhack.in/learn/dsa/problem/detonate-the-maximum-bombs) (Medium)
18. [Digit Operations to Make Two Integers Equal](https://www.internhack.in/learn/dsa/problem/digit-operations-to-make-two-integers-equal) (Medium)
19. [Evaluate Division](https://www.internhack.in/learn/dsa/problem/evaluate-division) (Medium)
20. [Find All Possible Recipes from Given Supplies](https://www.internhack.in/learn/dsa/problem/find-all-possible-recipes-from-given-supplies) (Medium)
21. [Find Champion II](https://www.internhack.in/learn/dsa/problem/find-champion-ii) (Medium)
22. [Add Edges to Make Degrees of All Nodes Even](https://www.internhack.in/learn/dsa/problem/add-edges-to-make-degrees-of-all-nodes-even) (Hard)
23. [Alien Dictionary](https://www.internhack.in/learn/dsa/problem/alien-dictionary) (Hard)
24. [Build a Matrix With Conditions](https://www.internhack.in/learn/dsa/problem/build-a-matrix-with-conditions) (Hard)
25. [Cat and Mouse](https://www.internhack.in/learn/dsa/problem/cat-and-mouse) (Hard)
26. [Cat and Mouse II](https://www.internhack.in/learn/dsa/problem/cat-and-mouse-ii) (Hard)
27. [Check for Contradictions in Equations](https://www.internhack.in/learn/dsa/problem/check-for-contradictions-in-equations) (Hard)
28. [Checking Existence of Edge Length Limited Paths](https://www.internhack.in/learn/dsa/problem/checking-existence-of-edge-length-limited-paths) (Hard)
29. [Checking Existence of Edge Length Limited Paths II](https://www.internhack.in/learn/dsa/problem/checking-existence-of-edge-length-limited-paths-ii) (Hard)
30. [Collect Coins in a Tree](https://www.internhack.in/learn/dsa/problem/collect-coins-in-a-tree) (Hard)
31. [Count Pairs Of Nodes](https://www.internhack.in/learn/dsa/problem/count-pairs-of-nodes) (Hard)
32. [Count the Number of Houses at a Certain Distance II](https://www.internhack.in/learn/dsa/problem/count-the-number-of-houses-at-a-certain-distance-ii) (Hard)
33. [Count Visited Nodes in a Directed Graph](https://www.internhack.in/learn/dsa/problem/count-visited-nodes-in-a-directed-graph) (Hard)
34. [Count Ways to Build Rooms in an Ant Colony](https://www.internhack.in/learn/dsa/problem/count-ways-to-build-rooms-in-an-ant-colony) (Hard)
35. [Couples Holding Hands](https://www.internhack.in/learn/dsa/problem/couples-holding-hands) (Hard)
36. [Cracking the Safe](https://www.internhack.in/learn/dsa/problem/cracking-the-safe) (Hard)
37. [Critical Connections in a Network](https://www.internhack.in/learn/dsa/problem/critical-connections-in-a-network) (Hard)
38. [Design Excel Sum Formula](https://www.internhack.in/learn/dsa/problem/design-excel-sum-formula) (Hard)
39. [Design Graph With Shortest Path Calculator](https://www.internhack.in/learn/dsa/problem/design-graph-with-shortest-path-calculator) (Hard)
40. [Distance to a Cycle in Undirected Graph](https://www.internhack.in/learn/dsa/problem/distance-to-a-cycle-in-undirected-graph) (Hard)
41. [Divide Nodes Into the Maximum Number of Groups](https://www.internhack.in/learn/dsa/problem/divide-nodes-into-the-maximum-number-of-groups) (Hard)
42. [Find All People With Secret](https://www.internhack.in/learn/dsa/problem/find-all-people-with-secret) (Hard)
43. [Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree](https://www.internhack.in/learn/dsa/problem/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree) (Hard)
44. [Find Edges in Shortest Paths](https://www.internhack.in/learn/dsa/problem/find-edges-in-shortest-paths) (Hard)
45. [Find Minimum Diameter After Merging Two Trees](https://www.internhack.in/learn/dsa/problem/find-minimum-diameter-after-merging-two-trees) (Hard)
46. [Find Shortest Path with K Hops](https://www.internhack.in/learn/dsa/problem/find-shortest-path-with-k-hops) (Hard)
47. [Frequencies of Shortest Supersequences](https://www.internhack.in/learn/dsa/problem/frequencies-of-shortest-supersequences) (Hard)
48. [Frog Position After T Seconds](https://www.internhack.in/learn/dsa/problem/frog-position-after-t-seconds) (Hard)
49. [Largest Color Value in a Directed Graph](https://www.internhack.in/learn/dsa/problem/largest-color-value-in-a-directed-graph) (Hard)
50. [Longest Cycle in a Graph](https://www.internhack.in/learn/dsa/problem/longest-cycle-in-a-graph) (Hard)
51. [Longest Increasing Path in a Matrix](https://www.internhack.in/learn/dsa/problem/longest-increasing-path-in-a-matrix) (Hard)
52. [Longest Path With Different Adjacent Characters](https://www.internhack.in/learn/dsa/problem/longest-path-with-different-adjacent-characters) (Hard)
53. [Maximum Candies You Can Get from Boxes](https://www.internhack.in/learn/dsa/problem/maximum-candies-you-can-get-from-boxes) (Hard)
54. [Maximum Employees to Be Invited to a Meeting](https://www.internhack.in/learn/dsa/problem/maximum-employees-to-be-invited-to-a-meeting) (Hard)
55. [Maximum Partition Factor](https://www.internhack.in/learn/dsa/problem/maximum-partition-factor) (Hard)
56. [Maximum Path Quality of a Graph](https://www.internhack.in/learn/dsa/problem/maximum-path-quality-of-a-graph) (Hard)
57. [Maximum Score of a Node Sequence](https://www.internhack.in/learn/dsa/problem/maximum-score-of-a-node-sequence) (Hard)
58. [Maximum Sum of Edge Values in a Graph](https://www.internhack.in/learn/dsa/problem/maximum-sum-of-edge-values-in-a-graph) (Hard)
59. [Maximum XOR of Two Non-Overlapping Subtrees](https://www.internhack.in/learn/dsa/problem/maximum-xor-of-two-non-overlapping-subtrees) (Hard)
60. [Minimize Malware Spread](https://www.internhack.in/learn/dsa/problem/minimize-malware-spread) (Hard)
61. [Minimize Malware Spread II](https://www.internhack.in/learn/dsa/problem/minimize-malware-spread-ii) (Hard)
62. [Minimize Maximum Value in a Grid](https://www.internhack.in/learn/dsa/problem/minimize-maximum-value-in-a-grid) (Hard)
63. [Minimum Cost to Convert String II](https://www.internhack.in/learn/dsa/problem/minimum-cost-to-convert-string-ii) (Hard)
64. [Minimum Cost to Make at Least One Valid Path in a Grid](https://www.internhack.in/learn/dsa/problem/minimum-cost-to-make-at-least-one-valid-path-in-a-grid) (Hard)
65. [Minimum Cost to Reach Destination in Time](https://www.internhack.in/learn/dsa/problem/minimum-cost-to-reach-destination-in-time) (Hard)
66. [Minimum Cost Walk in Weighted Graph](https://www.internhack.in/learn/dsa/problem/minimum-cost-walk-in-weighted-graph) (Hard)
67. [Minimum Degree of a Connected Trio in a Graph](https://www.internhack.in/learn/dsa/problem/minimum-degree-of-a-connected-trio-in-a-graph) (Hard)
68. [Minimum Edge Reversals So Every Node Is Reachable](https://www.internhack.in/learn/dsa/problem/minimum-edge-reversals-so-every-node-is-reachable) (Hard)
69. [Minimum Edge Weight Equilibrium Queries in a Tree](https://www.internhack.in/learn/dsa/problem/minimum-edge-weight-equilibrium-queries-in-a-tree) (Hard)
70. [Minimum Obstacle Removal to Reach Corner](https://www.internhack.in/learn/dsa/problem/minimum-obstacle-removal-to-reach-corner) (Hard)
71. [Minimum Operations to Remove Adjacent Ones in Matrix](https://www.internhack.in/learn/dsa/problem/minimum-operations-to-remove-adjacent-ones-in-matrix) (Hard)
72. [Minimum Runes to Add to Cast Spell](https://www.internhack.in/learn/dsa/problem/minimum-runes-to-add-to-cast-spell) (Hard)
73. [Minimum Time to Break Locks II](https://www.internhack.in/learn/dsa/problem/minimum-time-to-break-locks-ii) (Hard)
74. [Minimum Time to Visit a Cell In a Grid](https://www.internhack.in/learn/dsa/problem/minimum-time-to-visit-a-cell-in-a-grid) (Hard)
75. [Minimum Weighted Subgraph With the Required Paths](https://www.internhack.in/learn/dsa/problem/minimum-weighted-subgraph-with-the-required-paths) (Hard)
76. [Modify Graph Edge Weights](https://www.internhack.in/learn/dsa/problem/modify-graph-edge-weights) (Hard)
77. [Number of Good Paths](https://www.internhack.in/learn/dsa/problem/number-of-good-paths) (Hard)
78. [Number of Increasing Paths in a Grid](https://www.internhack.in/learn/dsa/problem/number-of-increasing-paths-in-a-grid) (Hard)
79. [Number of Possible Sets of Closing Branches](https://www.internhack.in/learn/dsa/problem/number-of-possible-sets-of-closing-branches) (Hard)
80. [Number Of Ways To Reconstruct A Tree](https://www.internhack.in/learn/dsa/problem/number-of-ways-to-reconstruct-a-tree) (Hard)
81. [Optimize Water Distribution in a Village](https://www.internhack.in/learn/dsa/problem/optimize-water-distribution-in-a-village) (Hard)
82. [Parallel Courses II](https://www.internhack.in/learn/dsa/problem/parallel-courses-ii) (Hard)
83. [Parallel Courses III](https://www.internhack.in/learn/dsa/problem/parallel-courses-iii) (Hard)
84. [Path Existence Queries in a Graph II](https://www.internhack.in/learn/dsa/problem/path-existence-queries-in-a-graph-ii) (Hard)
85. [Process Restricted Friend Requests](https://www.internhack.in/learn/dsa/problem/process-restricted-friend-requests) (Hard)
86. [Rank Transform of a Matrix](https://www.internhack.in/learn/dsa/problem/rank-transform-of-a-matrix) (Hard)
87. [Reachable Nodes In Subdivided Graph](https://www.internhack.in/learn/dsa/problem/reachable-nodes-in-subdivided-graph) (Hard)
88. [Reconstruct Itinerary](https://www.internhack.in/learn/dsa/problem/reconstruct-itinerary) (Hard)
89. [Redundant Connection II](https://www.internhack.in/learn/dsa/problem/redundant-connection-ii) (Hard)
90. [Remove Max Number of Edges to Keep Graph Fully Traversable](https://www.internhack.in/learn/dsa/problem/remove-max-number-of-edges-to-keep-graph-fully-traversable) (Hard)
91. [Second Minimum Time to Reach Destination](https://www.internhack.in/learn/dsa/problem/second-minimum-time-to-reach-destination) (Hard)
92. [Shortest Cycle in a Graph](https://www.internhack.in/learn/dsa/problem/shortest-cycle-in-a-graph) (Hard)
93. [Shortest Path Visiting All Nodes](https://www.internhack.in/learn/dsa/problem/shortest-path-visiting-all-nodes) (Hard)
94. [Sort Items by Groups Respecting Dependencies](https://www.internhack.in/learn/dsa/problem/sort-items-by-groups-respecting-dependencies) (Hard)
95. [Strange Printer II](https://www.internhack.in/learn/dsa/problem/strange-printer-ii) (Hard)
96. [String Transforms Into Another String](https://www.internhack.in/learn/dsa/problem/string-transforms-into-another-string) (Hard)
97. [Sum of Distances in Tree](https://www.internhack.in/learn/dsa/problem/sum-of-distances-in-tree) (Hard)
98. [The Maze III](https://www.internhack.in/learn/dsa/problem/the-maze-iii) (Hard)
99. [The Most Similar Path in a Graph](https://www.internhack.in/learn/dsa/problem/the-most-similar-path-in-a-graph) (Hard)
100. [Valid Arrangement of Pairs](https://www.internhack.in/learn/dsa/problem/valid-arrangement-of-pairs) (Hard)

## Companies that ask graph theory problems

- [Google](https://www.internhack.in/learn/dsa/companies/google): 70 of these problems
- [Amazon](https://www.internhack.in/learn/dsa/companies/amazon): 49 of these problems
- [Microsoft](https://www.internhack.in/learn/dsa/companies/microsoft): 34 of these problems
- [Meta](https://www.internhack.in/learn/dsa/companies/meta): 29 of these problems
- [Uber](https://www.internhack.in/learn/dsa/companies/uber): 26 of these problems
- [Bloomberg](https://www.internhack.in/learn/dsa/companies/bloomberg): 20 of these problems
- [Apple](https://www.internhack.in/learn/dsa/companies/apple): 11 of these problems
- [Oracle](https://www.internhack.in/learn/dsa/companies/oracle): 11 of these problems
- [Tiktok](https://www.internhack.in/learn/dsa/companies/tiktok): 11 of these problems
- [Phonepe](https://www.internhack.in/learn/dsa/companies/phonepe): 10 of these problems
- [Citadel](https://www.internhack.in/learn/dsa/companies/citadel): 10 of these problems
- [Snapchat](https://www.internhack.in/learn/dsa/companies/snapchat): 8 of these problems

## Before your interview

Most resumes are filtered by software before a recruiter reads them. [Check your resume ATS score free](https://www.internhack.in/ats-score/try), no signup needed.

## Other DSA topics

- [Array](https://www.internhack.in/learn/dsa/array) (1869)
- [String](https://www.internhack.in/learn/dsa/string) (775)
- [Hash Table](https://www.internhack.in/learn/dsa/hash-table) (708)
- [Math](https://www.internhack.in/learn/dsa/math) (564)
- [Dynamic Programming](https://www.internhack.in/learn/dsa/dynamic-programming) (557)
- [Sorting](https://www.internhack.in/learn/dsa/sorting) (464)
- [Greedy](https://www.internhack.in/learn/dsa/greedy) (407)
- [Depth-First Search](https://www.internhack.in/learn/dsa/depth-first-search) (314)
- [Binary Search](https://www.internhack.in/learn/dsa/binary-search) (298)
- [Matrix](https://www.internhack.in/learn/dsa/matrix) (246)
- [Breadth-First Search](https://www.internhack.in/learn/dsa/breadth-first-search) (245)
- [Bit Manipulation](https://www.internhack.in/learn/dsa/bit-manipulation) (238)
- [Tree](https://www.internhack.in/learn/dsa/tree) (235)
- [Two Pointers](https://www.internhack.in/learn/dsa/two-pointers) (217)
- [Prefix Sum](https://www.internhack.in/learn/dsa/prefix-sum) (204)
- [Database](https://www.internhack.in/learn/dsa/database) (197)
- [Heap (Priority Queue)](https://www.internhack.in/learn/dsa/heap-priority-queue) (196)
- [Simulation](https://www.internhack.in/learn/dsa/simulation) (177)
- [Counting](https://www.internhack.in/learn/dsa/counting) (174)
- [Binary Tree](https://www.internhack.in/learn/dsa/binary-tree) (169)

## Related

- [Home](https://www.internhack.in/)
- [Learn](https://www.internhack.in/learn)
- [DSA](https://www.internhack.in/learn/dsa)
