Basic Graph Theory Problems for Coding Interviews
34 basic Graph Theory problems from real coding interviews, each with test cases you can run online. By difficulty they split into 34 basic, 0 intermediate and 0 advanced. The companies that ask them most often are Amazon, Google, Microsoft, Meta.
Solve a few problems of each level, name the pattern after each one and revisit the ones that needed a hint a week later. Practise stating the time and space complexity and the edge cases before you code.
Coding problems
- Skyline Key Points (Basic)
- Maximum Weight Cut (Basic)
- Tree Distance Queries (Basic)
- Number of Connected Components (Basic)
- Find All Ancestors in DAG (Basic)
- Maximum Path Quality (Basic)
- Maximum Flow With Lower Bounds (Basic)
- Steiner Tree Small Graph (Basic)
- Insert GCDs Between Adjacent Nodes (Basic)
- Minimum Depth of Binary Tree (Basic)
- Minimum Vertices to Reach All Nodes (Basic)
- Find Center of Star Graph (Basic)
- Find if Path Exists in Graph (Basic)
- Rectangle Overlap (Basic)
- Minimum Cuts to Divide a Circle (Basic)
- Message Route Node Count (Basic)
- Nodes at Exact Distance K (Basic)
- Is Edge List a Tree (Basic)
- Doubled Polygon Area (Basic)
- Component Count After Each Edge (Basic)
- Isolated Vertex Count (Basic)
- Leaf Vertex Count (Basic)
- Highest Degree Vertex (Basic)
- Regular Graph Check (Basic)
- Complete Graph Check (Basic)
- Common Neighbour Count (Basic)
- Source Vertex Count (Basic)
- Sink Vertex Count (Basic)
- Odd Degree Vertex Count (Basic)
- Edge Density Percent (Basic)
- Reachable Vertex Count (Basic)
- Average Degree Rounded Down (Basic)
- Polygon Diagonal Count (Basic)
- Rectangles Overlap Check (Basic)
Related
Frequently asked questions
How do I get good at graph theory problems?
Practise by level, name the pattern after you solve each problem and review the ones you needed hints for. The list is ordered so you can start with the basic ones.
Can I run graph theory problems online here?
Yes. Each problem opens in an editor that runs your code against test cases in Java, Python, C++, Go, JavaScript and more.