LeetCodechevron_rightSolve patternschevron_rightgraph
schemaReusable solving pattern

graph Pattern

Pattern hubs are for building transferable solving frames. Learn the recognition signals first, then drill state definition, update rules, and edge explanation until the pattern feels stable.

database13 problemstune1/4/8 difficulty mixcategory6 linked topics

Pattern brief

Recognize first

Look for nodes with no incoming edges as a hint for mandatory inclusion.

Solve rhythm

State the active state and invariant first, explain how each update preserves them, then pressure-test with counterexamples.

Most common miss

Assuming any node can be included without checking in-degree may lead to non-minimal sets.

Recognition signals

  • Look for nodes with no incoming edges as a hint for mandatory inclusion.
  • Consider in-degree counting to avoid full traversal of the DAG.
  • The hint about thinking in reverse is a strong signal to identify which color could have been printed last.

Solve flow

  1. 1. Define the active state/window.
  2. 2. Update state while preserving invariants.
  3. 3. Validate with edge-heavy examples.

Common misses

  • Assuming any node can be included without checking in-degree may lead to non-minimal sets.
  • Adding dependencies in the wrong direction is the most common bug; if color d appears inside color c's rectangle, then c must come before d.
  • Double-counting a road that connects both cities when calculating network rank.

Recommended Ladder

Problem bank

graph pattern bank

Start by scanning with search or difficulty filters, then narrow by linked topics. The bank continues loading inside its own container so the page stays readable.

Progressive pattern bank

Use it to build pattern understanding first, then expand into the full corpus.

hourglass_bottomScroll inside to continue
search
tuneDifficulty
categoryTopic focus

Showing 13 / 13 problems

#TitleDifficulty
1557

Minimum Number of Vertices to Reach All Nodes

Identify the minimum set of vertices in a directed acyclic graph from which all nodes are reachable efficiently using gr…

Medium
1591

Strange Printer II

Solve Strange Printer II by building color dependencies from bounding rectangles and checking whether a topological orde…

Hard
1615

Maximal Network Rank

Calculate the maximum network rank of two cities by analyzing all city pairs using a graph-driven solution strategy effi…

Medium
1761

Minimum Degree of a Connected Trio in a Graph

Find the minimum degree of a connected trio in a graph using enumeration over nodes and edges.

Hard
1791

Find Center of Star Graph

Find the center node of a star graph, where one node connects to all others.

Easy
2203

Minimum Weighted Subgraph With the Required Paths

Find the minimum weighted subgraph that connects three specified nodes in a directed graph with constraints.

Hard
2242

Maximum Score of a Node Sequence

Find the maximum score of a valid node sequence in an undirected graph with given node scores and edges.

Hard
2374

Node With Highest Edge Score

Determine the node with the highest edge score in a graph using hash table aggregation and careful index tracking.

Medium
2392

Build a Matrix With Conditions

Solve the matrix-building problem by using graph indegree and topological sorting to satisfy given row and column constr…

Hard
2508

Add Edges to Make Degrees of All Nodes Even

Determine if it's possible to add at most two edges to make all node degrees even in an undirected graph.

Hard
2603

Collect Coins in a Tree

The "Collect Coins in a Tree" problem requires traversing a tree to collect coins in the fewest steps while returning to…

Hard
2924

Find Champion II

Identify the strongest team in a tournament DAG using graph-driven logic, ensuring correct handling of in-degree zero ch…

Medium
3435

Frequencies of Shortest Supersequences

Compute all unique shortest common supersequences of given words using graph indegree tracking and topological ordering …

Hard

Continue by topic

Once the pattern itself feels familiar, move back into concrete topic hubs so you can separate the pattern from the changing problem context.

route

Guided Practice Path

AI recommends problems by your level and tracks your progress.

Start Guided Patharrow_forward
Graph-driven solution strategy LeetCode Pattern: 13 Solutions