Graph Problems
141 Graph LeetCode problems · Solve with AI-powered hints & step-by-step explanations.
Learn the coding interview patterns behind these problems, including Graph interview patterns.
Start with these
All Graph problems
133 Clone Graph Medium207 Course Schedule Medium210 Course Schedule II Medium310 Minimum Height Trees Medium329 Longest Increasing Path in a Matrix Hard332 Reconstruct Itinerary Hard399 Evaluate Division Medium547 Number of Provinces Medium684 Redundant Connection Medium685 Redundant Connection II Hard743 Network Delay Time Medium753 Cracking the Safe Hard765 Couples Holding Hands Hard785 Is Graph Bipartite? Medium787 Cheapest Flights Within K Stops Medium797 All Paths From Source to Target Medium802 Find Eventual Safe States Medium834 Sum of Distances in Tree Hard841 Keys and Rooms Medium847 Shortest Path Visiting All Nodes Hard851 Loud and Rich Medium882 Reachable Nodes In Subdivided Graph Hard886 Possible Bipartition Medium913 Cat and Mouse Hard924 Minimize Malware Spread Hard928 Minimize Malware Spread II Hard947 Most Stones Removed with Same Row or Column Medium990 Satisfiability of Equality Equations Medium997 Find the Town Judge Easy1042 Flower Planting With No Adjacent Medium1129 Shortest Path with Alternating Colors Medium1192 Critical Connections in a Network Hard1203 Sort Items by Groups Respecting Dependencies Hard1298 Maximum Candies You Can Get from Boxes Hard1311 Get Watched Videos by Your Friends Medium1319 Number of Operations to Make Network Connected Medium1334 Find the City With the Smallest Number of Neighbors at a Threshold Distance Medium1361 Validate Binary Tree Nodes Medium1368 Minimum Cost to Make at Least One Valid Path in a Grid Hard1377 Frog Position After T Seconds Hard1462 Course Schedule IV Medium1466 Reorder Routes to Make All Paths Lead to the City Zero Medium1489 Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree Hard1494 Parallel Courses II Hard1514 Path with Maximum Probability Medium1557 Minimum Number of Vertices to Reach All Nodes Medium1579 Remove Max Number of Edges to Keep Graph Fully Traversable Hard1584 Min Cost to Connect All Points Medium1591 Strange Printer II Hard1615 Maximal Network Rank Medium1632 Rank Transform of a Matrix Hard1697 Checking Existence of Edge Length Limited Paths Hard1719 Number Of Ways To Reconstruct A Tree Hard1728 Cat and Mouse II Hard1761 Minimum Degree of a Connected Trio in a Graph Hard1782 Count Pairs Of Nodes Hard1786 Number of Restricted Paths From First to Last Node Medium1791 Find Center of Star Graph Easy1857 Largest Color Value in a Directed Graph Hard1916 Count Ways to Build Rooms in an Ant Colony Hard1928 Minimum Cost to Reach Destination in Time Hard1971 Find if Path Exists in Graph Easy1976 Number of Ways to Arrive at Destination Medium2039 The Time When the Network Becomes Idle Medium2045 Second Minimum Time to Reach Destination Hard2050 Parallel Courses III Hard2065 Maximum Path Quality of a Graph Hard2076 Process Restricted Friend Requests Hard2092 Find All People With Secret Hard2097 Valid Arrangement of Pairs Hard2101 Detonate the Maximum Bombs Medium2115 Find All Possible Recipes from Given Supplies Medium2127 Maximum Employees to Be Invited to a Meeting Hard2192 All Ancestors of a Node in a Directed Acyclic Graph Medium2203 Minimum Weighted Subgraph With the Required Paths Hard2242 Maximum Score of a Node Sequence Hard2246 Longest Path With Different Adjacent Characters Hard2285 Maximum Total Importance of Roads Medium2290 Minimum Obstacle Removal to Reach Corner Hard2316 Count Unreachable Pairs of Nodes in an Undirected Graph Medium2328 Number of Increasing Paths in a Grid Hard2359 Find Closest Node to Given Two Nodes Medium2360 Longest Cycle in a Graph Hard2368 Reachable Nodes With Restrictions Medium2374 Node With Highest Edge Score Medium2392 Build a Matrix With Conditions Hard2421 Number of Good Paths Hard2467 Most Profitable Path in a Tree Medium2477 Minimum Fuel Cost to Report to the Capital Medium2492 Minimum Score of a Path Between Two Cities Medium2493 Divide Nodes Into the Maximum Number of Groups Hard2497 Maximum Star Sum of a Graph Medium2508 Add Edges to Make Degrees of All Nodes Even Hard2577 Minimum Time to Visit a Cell In a Grid Hard2603 Collect Coins in a Tree Hard2608 Shortest Cycle in a Graph Hard2642 Design Graph With Shortest Path Calculator Hard2646 Minimize the Total Price of the Trips Hard2662 Minimum Cost of a Path With Special Roads Medium2685 Count the Number of Complete Components Medium2699 Modify Graph Edge Weights Hard2846 Minimum Edge Weight Equilibrium Queries in a Tree Hard2858 Minimum Edge Reversals So Every Node Is Reachable Hard2876 Count Visited Nodes in a Directed Graph Hard2924 Find Champion II Medium2959 Number of Possible Sets of Closing Branches Hard2976 Minimum Cost to Convert String I Medium2977 Minimum Cost to Convert String II Hard3015 Count the Number of Houses at a Certain Distance I Medium3017 Count the Number of Houses at a Certain Distance II Hard3108 Minimum Cost Walk in Weighted Graph Hard3112 Minimum Time to Visit Disappearing Nodes Medium3123 Find Edges in Shortest Paths Hard3203 Find Minimum Diameter After Merging Two Trees Hard3241 Time Taken to Mark All Nodes Hard3243 Shortest Distance After Road Addition Queries I Medium3244 Shortest Distance After Road Addition Queries II Hard3286 Find a Safe Walk Through a Grid Medium3310 Remove Methods From Project Medium3311 Construct 2D Grid Matching Graph Layout Hard3341 Find Minimum Time to Reach Last Room I Medium3342 Find Minimum Time to Reach Last Room II Medium3377 Digit Operations to Make Two Integers Equal Medium3387 Maximize Amount After Two Days of Conversions Medium3419 Minimize the Maximum Edge Weight of Graph Medium3435 Frequencies of Shortest Supersequences Hard3493 Properties Graph Medium3528 Unit Conversion I Medium3530 Maximum Profit from Valid Topological Order in DAG Hard3532 Path Existence Queries in a Graph I Medium3534 Path Existence Queries in a Graph II Hard3543 Maximum Weighted K-Edge Path Medium3547 Maximum Sum of Edge Values in a Graph Hard3594 Minimum Time to Transport All Individuals Hard3600 Maximize Spanning Tree Stability with Upgrades Hard3604 Minimum Time to Reach Destination in Directed Graph Medium3607 Power Grid Maintenance Medium3608 Minimum Time for K Connected Components Medium3613 Minimize Maximum Component Cost Medium3615 Longest Palindromic Path in Graph Hard3620 Network Recovery Pathways Hard