Graph Problems
Master graph problems with AI-powered solutions. Get instant coding assistance during your technical interviews for all 110 problems in this category.
Total Problems: 110
Easy: 3
Medium: 52
Hard: 55
Showing 50 of 110 problems
Problems
Scroll within this area to browse all problems
#
Title
Difficulty
Graph LeetCode Problems List
- 207. Course Schedule - Medium - GraphThere are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i... Topics: Depth-First Search, Breadth-First Search, Graph, Topological Sort
- 803. Cheapest Flights Within K Stops - Medium - GraphThere are n cities connected by some number of flights. You are given an array flights where flights[i] = [fromi, toi, pricei] indicates that there is... Topics: Dynamic Programming, Depth-First Search, Breadth-First Search, Graph, Heap (Priority Queue), Shortest Path
- 210. Course Schedule II - Medium - GraphThere are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i... Topics: Depth-First Search, Breadth-First Search, Graph, Topological Sort
- 801. Is Graph Bipartite? - Medium - GraphThere is an undirected graph with n nodes, where each node is numbered between 0 and n - 1. You are given a 2D array graph, where graph[u] is an array... Topics: Depth-First Search, Breadth-First Search, Union Find, Graph
- 133. Clone Graph - Medium - GraphGiven a reference of a node in a connected undirected graph. Return a deep copy (clone) of the graph. Each node in the graph contains a value (int) an... Topics: Hash Table, Depth-First Search, Breadth-First Search, Graph
- 329. Longest Increasing Path in a Matrix - Hard - GraphGiven an m x n integers matrix, return the length of the longest increasing path in matrix. From each cell, you can either move in four directions: le... Topics: Array, Dynamic Programming, Depth-First Search, Breadth-First Search, Graph, Topological Sort, Memoization, Matrix
- 3613. Maximize Amount After Two Days of Conversions - Medium - GraphYou are given a string initialCurrency, and you start with 1.0 of initialCurrency. You are also given four arrays with currency pairs (strings) and ra... Topics: Array, String, Depth-First Search, Breadth-First Search, Graph
- 399. Evaluate Division - Medium - GraphYou are given an array of variable pairs equations and an array of real numbers values, where equations[i] = [Ai, Bi] and values[i] represent the equa... Topics: Array, String, Depth-First Search, Breadth-First Search, Union Find, Graph, Shortest Path
- 3863. Power Grid Maintenance - Medium - GraphYou are given an integer c representing c power stations, each with a unique identifier id from 1 to c (1‑based indexing). These stations are intercon... Topics: Array, Hash Table, Depth-First Search, Breadth-First Search, Union Find, Graph, Heap (Priority Queue), Ordered Set
- 1558. Course Schedule IV - Medium - GraphThere are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i... Topics: Depth-First Search, Breadth-First Search, Graph, Topological Sort
- 744. Network Delay Time - Medium - GraphYou are given a network of n nodes, labeled from 1 to n. You are also given times, a list of travel times as directed edges times[i] = (ui, vi, wi), w... Topics: Depth-First Search, Breadth-First Search, Graph, Heap (Priority Queue), Shortest Path
- 684. Redundant Connection - Medium - GraphIn this problem, a tree is an undirected graph that is connected and has no cycles. You are given a graph that started as a tree with n nodes labeled ... Topics: Depth-First Search, Breadth-First Search, Union Find, Graph
- 1039. Find the Town Judge - Easy - GraphIn a town, there are n people labeled from 1 to n. There is a rumor that one of these people is secretly the town judge. If the town judge exists, the... Topics: Array, Hash Table, Graph
- 2121. Find if Path Exists in Graph - Easy - GraphThere is a bi-directional graph with n vertices, where each vertex is labeled from 0 to n - 1 (inclusive). The edges in the graph are represented as a... Topics: Depth-First Search, Breadth-First Search, Union Find, Graph
- 770. Couples Holding Hands - Hard - GraphThere are n couples sitting in 2n seats arranged in a row and want to hold hands. The people and seats are represented by an integer array row where r... Topics: Greedy, Depth-First Search, Breadth-First Search, Union Find, Graph
- 547. Number of Provinces - Medium - GraphThere are n cities. Some of them are connected, while some are not. If city a is connected directly with city b, and city b is connected directly with... Topics: Depth-First Search, Breadth-First Search, Union Find, Graph
- 877. Shortest Path Visiting All Nodes - Hard - GraphYou have an undirected, connected graph of n nodes labeled from 0 to n - 1. You are given an array graph where graph[i] is a list of all the nodes con... Topics: Dynamic Programming, Bit Manipulation, Breadth-First Search, Graph, Bitmask
- 813. All Paths From Source to Target - Medium - GraphGiven a directed acyclic graph (DAG) of n nodes labeled from 0 to n - 1, find all possible paths from node 0 to node n - 1 and return them in any orde... Topics: Backtracking, Depth-First Search, Breadth-First Search, Graph
- 2364. Longest Path With Different Adjacent Characters - Hard - GraphYou are given a tree (i.e. a connected, undirected graph that has no cycles) rooted at node 0 consisting of n nodes numbered from 0 to n - 1. The tree... Topics: Array, String, Tree, Depth-First Search, Graph, Topological Sort
- 2793. Count the Number of Complete Components - Medium - GraphYou are given an integer n. There is an undirected graph with n vertices, numbered from 0 to n - 1. You are given a 2D integer array edges where edges... Topics: Depth-First Search, Breadth-First Search, Union Find, Graph
- 2439. Longest Cycle in a Graph - Hard - GraphYou are given a directed graph of n nodes numbered from 0 to n - 1, where each node has at most one outgoing edge. The graph is represented with a giv... Topics: Depth-First Search, Breadth-First Search, Graph, Topological Sort
- 1300. Critical Connections in a Network - Hard - GraphThere are n servers numbered from 0 to n - 1 connected by undirected server-to-server connections forming a network where connections[i] = [ai, bi] re... Topics: Depth-First Search, Graph, Biconnected Component
- 332. Reconstruct Itinerary - Hard - GraphYou are given a list of airline tickets where tickets[i] = [fromi, toi] represent the departure and the arrival airports of one flight. Reconstruct th... Topics: Depth-First Search, Graph, Eulerian Circuit
- 2206. Detonate the Maximum Bombs - Medium - GraphYou are given a list of bombs. The range of a bomb is defined as the area where its effect can be felt. This area is in the shape of a circle with the... Topics: Array, Math, Depth-First Search, Breadth-First Search, Graph, Geometry
- 3627. Find Minimum Time to Reach Last Room I - Medium - GraphThere is a dungeon with n x m rooms arranged as a grid. You are given a 2D array moveTime of size n x m, where moveTime[i][j] represents the minimum t... Topics: Array, Graph, Heap (Priority Queue), Matrix, Shortest Path
- 310. Minimum Height Trees - Medium - GraphA tree is an undirected graph in which any two vertices are connected by exactly one path. In other words, any connected graph without simple cycles i... Topics: Depth-First Search, Breadth-First Search, Graph, Topological Sort
- 1275. Validate Binary Tree Nodes - Medium - GraphYou have n binary tree nodes numbered from 0 to n - 1 where node i has two children leftChild[i] and rightChild[i], return true if and only if all the... Topics: Tree, Depth-First Search, Breadth-First Search, Union Find, Graph, Binary Tree
- 1706. Min Cost to Connect All Points - Medium - GraphYou are given an array points representing integer coordinates of some points on a 2D-plane, where points[i] = [xi, yi]. The cost of connecting two po... Topics: Array, Union Find, Graph, Minimum Spanning Tree
- 2671. Shortest Cycle in a Graph - Hard - GraphThere is a bi-directional graph with n vertices, where each vertex is labeled from 0 to n - 1. The edges in the graph are represented by a given 2D in... Topics: Breadth-First Search, Graph
- 1032. Satisfiability of Equality Equations - Medium - GraphYou are given an array of strings equations that represent relationships between variables where each string equations[i] is of length 4 and takes one... Topics: Array, String, Union Find, Graph
- 685. Redundant Connection II - Hard - GraphIn this problem, a rooted tree is a directed graph such that, there is exactly one node (the root) for which all other nodes are descendants of this n... Topics: Depth-First Search, Breadth-First Search, Union Find, Graph
- 1916. Find Center of Star Graph - Easy - GraphThere is an undirected star graph consisting of n nodes labeled from 1 to n. A star graph is a graph where there is one center node and exactly n - 1 ... Topics: Graph
- 949. Cat and Mouse - Hard - GraphA game on an undirected graph is played by two players, Mouse and Cat, who alternate turns. The graph is given as follows: graph[a] is a list of all n... Topics: Math, Dynamic Programming, Graph, Topological Sort, Memoization, Game Theory
- 1493. Frog Position After T Seconds - Hard - GraphGiven an undirected tree consisting of n vertices numbered from 1 to n. A frog starts jumping from vertex 1. In one second, the frog jumps from its cu... Topics: Tree, Depth-First Search, Breadth-First Search, Graph
- 2409. Number of Increasing Paths in a Grid - Hard - GraphYou are given an m x n integer matrix grid, where you can move from a cell to any adjacent cell in all 4 directions. Return the number of strictly inc... Topics: Array, Dynamic Programming, Depth-First Search, Breadth-First Search, Graph, Topological Sort, Memoization, Matrix
- 1587. Parallel Courses II - Hard - GraphYou are given an integer n, which indicates that there are n courses labeled from 1 to n. You are also given an array relations where relations[i] = [... Topics: Dynamic Programming, Bit Manipulation, Graph, Bitmask
- 2171. Second Minimum Time to Reach Destination - Hard - GraphA city is represented as a bi-directional connected graph with n vertices where each vertex is labeled from 1 to n (inclusive). The edges in the graph... Topics: Breadth-First Search, Graph, Shortest Path
- 2686. Minimum Cost of a Path With Special Roads - Medium - GraphYou are given an array start where start = [startX, startY] represents your initial position (startX, startY) in a 2D space. You are also given the ar... Topics: Array, Graph, Heap (Priority Queue), Shortest Path
- 871. Keys and Rooms - Medium - GraphThere are n rooms labeled from 0 to n - 1 and all the rooms are locked except for room 0. Your goal is to visit all the rooms. However, you cannot ent... Topics: Depth-First Search, Breadth-First Search, Graph
- 2220. Find All Possible Recipes from Given Supplies - Medium - GraphYou have information about n different recipes. You are given a string array recipes and a 2D string array ingredients. The ith recipe has the name re... Topics: Array, Hash Table, String, Graph, Topological Sort
- 2151. The Time When the Network Becomes Idle - Medium - GraphThere is a network of n servers, labeled from 0 to n - 1. You are given a 2D integer array edges, where edges[i] = [ui, vi] indicates there is a messa... Topics: Array, Breadth-First Search, Graph
- 3919. Network Recovery Pathways - Hard - GraphYou are given a directed acyclic graph of n nodes numbered from 0 to n − 1. This is represented by a 2D array edges of length m, where edges[i] = [ui,... Topics: Array, Binary Search, Dynamic Programming, Graph, Topological Sort, Heap (Priority Queue), Shortest Path
- 1120. Flower Planting With No Adjacent - Medium - GraphYou have n gardens, labeled from 1 to n, and an array paths where paths[i] = [xi, yi] describes a bidirectional path between garden xi to garden yi. I... Topics: Depth-First Search, Breadth-First Search, Graph
- 964. Minimize Malware Spread II - Hard - GraphYou are given a network of n nodes represented as an n x n adjacency matrix graph, where the ith node is directly connected to the jth node if graph[i... Topics: Array, Hash Table, Depth-First Search, Breadth-First Search, Union Find, Graph
- 2472. Build a Matrix With Conditions - Hard - GraphYou are given a positive integer k. You are also given: a 2D integer array rowConditions of size n where rowConditions[i] = [abovei, belowi], and a 2D... Topics: Array, Graph, Topological Sort, Matrix
- 1456. Find the City With the Smallest Number of Neighbors at a Threshold Distance - Medium - GraphThere are n cities numbered from 0 to n-1. Given the array edges where edges[i] = [fromi, toi, weighti] represents a bidirectional and weighted edge b... Topics: Dynamic Programming, Graph, Shortest Path
- 1442. Number of Operations to Make Network Connected - Medium - GraphThere are n computers numbered from 0 to n - 1 connected by ethernet cables connections forming a network where connections[i] = [ai, bi] represents a... Topics: Depth-First Search, Breadth-First Search, Union Find, Graph
- 2590. Maximum Star Sum of a Graph - Medium - GraphThere is an undirected graph consisting of n nodes numbered from 0 to n - 1. You are given a 0-indexed integer array vals of length n where vals[i] de... Topics: Array, Greedy, Graph, Sorting, Heap (Priority Queue)
- 1613. Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree - Hard - GraphGiven a weighted undirected connected graph with n vertices numbered from 0 to n - 1, and an array edges where edges[i] = [ai, bi, weighti] represents... Topics: Union Find, Graph, Sorting, Minimum Spanning Tree, Strongly Connected Component
- 2189. Maximum Path Quality of a Graph - Hard - GraphThere is an undirected graph with n nodes numbered from 0 to n - 1 (inclusive). You are given a 0-indexed integer array values where values[i] is the ... Topics: Array, Backtracking, Graph
- 1485. Minimum Cost to Make at Least One Valid Path in a Grid - Hard - GraphGiven an m x n grid. Each cell of the grid has a sign pointing to the next cell you should visit if you are currently in this cell. The sign of grid[i... Topics: Array, Breadth-First Search, Graph, Heap (Priority Queue), Matrix, Shortest Path
- 2090. Number of Ways to Arrive at Destination - Medium - GraphYou are in a city that consists of n intersections numbered from 0 to n - 1 with bi-directional roads between some intersections. The inputs are gener... Topics: Dynamic Programming, Graph, Topological Sort, Shortest Path
- 3916. Minimum Time to Reach Destination in Directed Graph - Medium - GraphYou are given an integer n and a directed graph with n nodes labeled from 0 to n - 1. This is represented by a 2D array edges, where edges[i] = [ui, v... Topics: Graph, Heap (Priority Queue), Shortest Path
- 1424. Maximum Candies You Can Get from Boxes - Hard - GraphYou have n boxes labeled from 0 to n - 1. You are given four arrays: status, candies, keys, and containedBoxes where: status[i] is 1 if the ith box is... Topics: Array, Breadth-First Search, Graph
- 984. Most Stones Removed with Same Row or Column - Medium - GraphOn a 2D plane, we place n stones at some integer coordinate points. Each coordinate point may have at most one stone. A stone can be removed if it sha... Topics: Hash Table, Depth-First Search, Union Find, Graph
- 922. Possible Bipartition - Medium - GraphWe want to split a group of n people (labeled from 1 to n) into two groups of any size. Each person may dislike some other people, and they should not... Topics: Depth-First Search, Breadth-First Search, Union Find, Graph
- 1257. Rank Transform of a Matrix - Hard - GraphGiven an m x n matrix, return a new matrix answer where answer[row][col] is the rank of matrix[row][col]. The rank is an integer that represents how l... Topics: Array, Union Find, Graph, Topological Sort, Sorting, Matrix
- 3908. Minimum Time for K Connected Components - Medium - GraphYou are given an integer n and an undirected graph with n nodes labeled from 0 to n - 1. This is represented by a 2D array edges, where edges[i] = [ui... Topics: Binary Search, Union Find, Graph, Sorting
- 820. Find Eventual Safe States - Medium - GraphThere is a directed graph of n nodes with each node labeled from 0 to n - 1. The graph is represented by a 0-indexed 2D integer array graph where grap... Topics: Depth-First Search, Breadth-First Search, Graph, Topological Sort
- 3930. Longest Palindromic Path in Graph - Hard - GraphYou are given an integer n and an undirected graph with n nodes labeled from 0 to n - 1 and a 2D array edges, where edges[i] = [ui, vi] indicates an e... Topics: String, Dynamic Programming, Bit Manipulation, Graph, Bitmask
- 2582. Minimum Score of a Path Between Two Cities - Medium - GraphYou are given a positive integer n representing n cities numbered from 1 to n. You are also given a 2D array roads where roads[i] = [ai, bi, distancei... Topics: Depth-First Search, Breadth-First Search, Union Find, Graph
- 2678. Design Graph With Shortest Path Calculator - Hard - GraphThere is a directed weighted graph that consists of n nodes numbered from 0 to n - 1. The edges of the graph are initially represented by the given ar... Topics: Graph, Design, Heap (Priority Queue), Shortest Path
- 2403. Count Unreachable Pairs of Nodes in an Undirected Graph - Medium - GraphYou are given an integer n. There is an undirected graph with n nodes, numbered from 0 to n - 1. You are given a 2D integer array edges where edges[i]... Topics: Depth-First Search, Breadth-First Search, Union Find, Graph
- 1986. Largest Color Value in a Directed Graph - Hard - GraphThere is a directed graph of n colored nodes and m edges. The nodes are numbered from 0 to n - 1. You are given a string colors where colors[i] is a l... Topics: Hash Table, Dynamic Programming, Graph, Topological Sort, Memoization, Counting
- 754. Cracking the Safe - Hard - GraphThere is a safe protected by a password. The password is a sequence of n digits where each digit can be in the range [0, k - 1]. The safe has a peculi... Topics: Depth-First Search, Graph, Eulerian Circuit
- 918. Reachable Nodes In Subdivided Graph - Hard - GraphYou are given an undirected graph (the "original graph") with n nodes labeled from 0 to n - 1. You decide to subdivide each edge in the graph into a c... Topics: Graph, Heap (Priority Queue), Shortest Path
- 2040. Minimum Cost to Reach Destination in Time - Hard - GraphThere is a country of n cities numbered from 0 to n - 1 where all the cities are connected by bi-directional roads. The roads are represented as a 2D ... Topics: Array, Dynamic Programming, Graph
- 3720. Minimize the Maximum Edge Weight of Graph - Medium - GraphYou are given two integers, n and threshold, as well as a directed weighted graph of n nodes numbered from 0 to n - 1. The graph is represented by a 2... Topics: Binary Search, Depth-First Search, Breadth-First Search, Graph, Shortest Path
- 960. Minimize Malware Spread - Hard - GraphYou are given a network of n nodes represented as an n x n adjacency matrix graph, where the ith node is directly connected to the jth node if graph[i... Topics: Array, Hash Table, Depth-First Search, Breadth-First Search, Union Find, Graph
- 863. Sum of Distances in Tree - Hard - GraphThere is an undirected connected tree with n nodes labeled from 0 to n - 1 and n - 1 edges. You are given the integer n and the array edges where edge... Topics: Dynamic Programming, Tree, Depth-First Search, Graph
- 3105. Minimum Edge Reversals So Every Node Is Reachable - Hard - GraphThere is a simple directed graph with n nodes labeled from 0 to n - 1. The graph would form a tree if its edges were bi-directional. You are given an ... Topics: Dynamic Programming, Depth-First Search, Breadth-First Search, Graph
- 3809. Properties Graph - Medium - GraphYou are given a 2D integer array properties having dimensions n x m and an integer k. Define a function intersect(a, b) that returns the number of dis... Topics: Array, Hash Table, Depth-First Search, Breadth-First Search, Union Find, Graph
- 1727. Cat and Mouse II - Hard - GraphA game is played by a cat and a mouse named Cat and Mouse. The environment is represented by a grid of size rows x cols, where each element is a wall,... Topics: Array, Math, Dynamic Programming, Graph, Topological Sort, Memoization, Matrix, Game Theory
- 2455. Node With Highest Edge Score - Medium - GraphYou are given a directed graph with n nodes labeled from 0 to n - 1, where each node has exactly one outgoing edge. The graph is represented by a give... Topics: Hash Table, Graph
- 3310. Count the Number of Houses at a Certain Distance II - Hard - GraphYou are given three positive integers n, x, and y. In a city, there exist houses numbered 1 to n connected by n streets. There is a street connecting ... Topics: Graph, Prefix Sum
- 2717. Collect Coins in a Tree - Hard - GraphThere exists an undirected and unrooted tree with n nodes indexed from 0 to n - 1. You are given an integer n and a 2D integer array edges of length n... Topics: Array, Tree, Graph, Topological Sort
- 3271. Count the Number of Houses at a Certain Distance I - Medium - GraphYou are given three positive integers n, x, and y. In a city, there exist houses numbered 1 to n connected by n streets. There is a street connecting ... Topics: Breadth-First Search, Graph, Prefix Sum
- 1576. Reorder Routes to Make All Paths Lead to the City Zero - Medium - GraphThere are n cities numbered from 0 to n - 1 and n - 1 roads such that there is only one way to travel between two different cities (this network form ... Topics: Depth-First Search, Breadth-First Search, Graph
- 1661. Minimum Number of Vertices to Reach All Nodes - Medium - GraphGiven a directed acyclic graph, with n vertices numbered from 0 to n-1, and an array edges where edges[i] = [fromi, toi] represents a directed edge fr... Topics: Graph
- 1431. All Ancestors of a Node in a Directed Acyclic Graph - Medium - GraphYou are given a positive integer n representing the number of nodes of a Directed Acyclic Graph (DAG). The nodes are numbered from 0 to n - 1 (inclusi... Topics: Depth-First Search, Breadth-First Search, Graph, Topological Sort
- 3881. Minimize Maximum Component Cost - Medium - GraphYou are given an undirected connected graph with n nodes labeled from 0 to n - 1 and a 2D integer array edges where edges[i] = [ui, vi, wi] denotes an... Topics: Binary Search, Union Find, Graph, Sorting
- 2176. Parallel Courses III - Hard - GraphYou are given an integer n, which indicates that there are n courses labeled from 1 to n. You are also given a 2D integer array relations where relati... Topics: Array, Dynamic Programming, Graph, Topological Sort
- 2246. Maximum Employees to Be Invited to a Meeting - Hard - GraphA company is organizing a meeting and has a list of n employees, waiting to be invited. They have arranged for a large circular table, capable of seat... Topics: Depth-First Search, Graph, Topological Sort
- 3713. Frequencies of Shortest Supersequences - Hard - GraphYou are given an array of strings words. Find all shortest common supersequences (SCS) of words that are not permutations of each other. A shortest co... Topics: Array, String, Bit Manipulation, Graph, Topological Sort, Enumeration
- 2803. Modify Graph Edge Weights - Hard - GraphYou are given an undirected weighted connected graph containing n nodes labeled from 0 to n - 1, and an integer array edges where edges[i] = [ai, bi, ... Topics: Graph, Heap (Priority Queue), Shortest Path
- 3514. Shortest Distance After Road Addition Queries II - Hard - GraphYou are given an integer n and a 2D integer array queries. There are n cities numbered from 0 to n - 1. Initially, there is a unidirectional road from... Topics: Array, Greedy, Graph, Ordered Set
- 3578. Construct 2D Grid Matching Graph Layout - Hard - GraphYou are given a 2D integer array edges representing an undirected graph having n nodes, where edges[i] = [ui, vi] denotes an edge between nodes ui and... Topics: Array, Hash Table, Graph, Matrix
- 1738. Maximal Network Rank - Medium - GraphThere is an infrastructure of n cities with some number of roads connecting these cities. Each roads[i] = [ai, bi] indicates that there is a bidirecti... Topics: Graph
- 3845. Maximum Sum of Edge Values in a Graph - Hard - GraphYou are given an undirected connected graph of n nodes, numbered from 0 to n - 1. Each node is connected to at most 2 other nodes. The graph consists ... Topics: Math, Greedy, Graph
- 3896. Minimum Time to Transport All Individuals - Hard - GraphYou are given n individuals at a base camp who need to cross a river to reach a destination using a single boat. The boat can carry at most k people a... Topics: Array, Dynamic Programming, Bit Manipulation, Graph, Heap (Priority Queue), Shortest Path, Bitmask
- 3558. Find a Safe Walk Through a Grid - Medium - GraphYou are given an m x n binary matrix grid and an integer health. You start on the upper-left corner (0, 0) and would like to get to the lower-right co... Topics: Array, Breadth-First Search, Graph, Heap (Priority Queue), Matrix, Shortest Path
- 1325. Path with Maximum Probability - Medium - GraphYou are given an undirected weighted graph of n nodes (0-indexed), represented by an edge list where edges[i] = [a, b] is an undirected edge connectin... Topics: Array, Graph, Heap (Priority Queue), Shortest Path
- 3826. Maximum Profit from Valid Topological Order in DAG - Hard - GraphYou are given a Directed Acyclic Graph (DAG) with n nodes labeled from 0 to n - 1, represented by a 2D array edges, where edges[i] = [ui, vi] indicate... Topics: Array, Dynamic Programming, Bit Manipulation, Graph, Topological Sort, Bitmask
- 2505. Number of Good Paths - Hard - GraphThere is a tree (i.e. a connected, undirected graph with no cycles) consisting of n nodes numbered from 0 to n - 1 and exactly n - 1 edges. You are gi... Topics: Array, Hash Table, Tree, Union Find, Graph, Sorting
- 3140. Count Visited Nodes in a Directed Graph - Hard - GraphThere is a directed graph consisting of n nodes numbered from 0 to n - 1 and n directed edges. You are given a 0-indexed array edges where edges[i] in... Topics: Dynamic Programming, Graph, Memoization
- 3902. Maximize Spanning Tree Stability with Upgrades - Hard - GraphYou are given an integer n, representing n nodes numbered from 0 to n - 1 and a list of edges, where edges[i] = [ui, vi, si, musti]: ui and vi indicat... Topics: Binary Search, Greedy, Union Find, Graph, Minimum Spanning Tree
- 3348. Minimum Cost Walk in Weighted Graph - Hard - GraphThere is an undirected weighted graph with n vertices labeled from 0 to n - 1. You are given the integer n and an array edges, where edges[i] = [ui, v... Topics: Array, Bit Manipulation, Union Find, Graph
- 3079. Minimum Edge Weight Equilibrium Queries in a Tree - Hard - GraphThere is an undirected tree with n nodes labeled from 0 to n - 1. You are given the integer n and a 2D integer array edges of length n - 1, where edge... Topics: Array, Tree, Graph, Strongly Connected Component
- 3439. Find Minimum Diameter After Merging Two Trees - Hard - GraphThere exist two undirected trees with n and m nodes, numbered from 0 to n - 1 and from 0 to m - 1, respectively. You are given two 2D integer arrays e... Topics: Tree, Depth-First Search, Breadth-First Search, Graph
- 1701. Remove Max Number of Edges to Keep Graph Fully Traversable - Hard - GraphAlice and Bob have an undirected graph of n nodes and three types of edges: Type 1: Can be traversed by Alice only. Type 2: Can be traversed by Bob on... Topics: Union Find, Graph
- 2564. Most Profitable Path in a Tree - Medium - GraphThere is an undirected tree with n nodes labeled from 0 to n - 1, rooted at node 0. You are given a 2D integer array edges of length n - 1 where edges... Topics: Array, Tree, Depth-First Search, Breadth-First Search, Graph
- 3235. Minimum Cost to Convert String I - Medium - GraphYou are given two 0-indexed strings source and target, both of length n and consisting of lowercase English letters. You are also given two 0-indexed ... Topics: Array, String, Graph, Shortest Path
- 2568. Minimum Fuel Cost to Report to the Capital - Medium - GraphThere is a tree (i.e., a connected, undirected graph with no cycles) structure country network consisting of n cities numbered from 0 to n - 1 and exa... Topics: Tree, Depth-First Search, Breadth-First Search, Graph
- 2379. Maximum Total Importance of Roads - Medium - GraphYou are given an integer n denoting the number of cities in a country. The cities are numbered from 0 to n - 1. You are also given a 2D integer array ... Topics: Greedy, Graph, Sorting, Heap (Priority Queue)
- 2375. Minimum Obstacle Removal to Reach Corner - Hard - GraphYou are given a 0-indexed 2D integer array grid of size m x n. Each cell has one of two values: 0 represents an empty cell, 1 represents an obstacle t... Topics: Array, Breadth-First Search, Graph, Heap (Priority Queue), Matrix, Shortest Path
- 2321. Minimum Weighted Subgraph With the Required Paths - Hard - GraphYou are given an integer n denoting the number of nodes of a weighted directed graph. The nodes are numbered from 0 to n - 1. You are also given a 2D ... Topics: Graph, Shortest Path
- 3386. Find Edges in Shortest Paths - Hard - GraphYou are given an undirected weighted graph of n nodes numbered from 0 to n - 1. The graph consists of m edges represented by a 2D array edges, where e... Topics: Depth-First Search, Breadth-First Search, Graph, Heap (Priority Queue), Shortest Path
- 2583. Divide Nodes Into the Maximum Number of Groups - Hard - GraphYou are given a positive integer n representing the number of nodes in an undirected graph. The nodes are labeled from 1 to n. You are also given a 2D... Topics: Depth-First Search, Breadth-First Search, Union Find, Graph
- 1229. Shortest Path with Alternating Colors - Medium - GraphYou are given an integer n, the number of nodes in a directed graph where the nodes are labeled from 0 to n - 1. Each edge is red or blue in this grap... Topics: Breadth-First Search, Graph
- 1815. Checking Existence of Edge Length Limited Paths - Hard - GraphAn undirected graph of n nodes is defined by edgeList, where edgeList[i] = [ui, vi, disi] denotes an edge between nodes ui and vi with distance disi. ... Topics: Array, Two Pointers, Union Find, Graph, Sorting
Related LeetCode Topics
- Array LeetCode Problems
- Backtracking LeetCode Problems
- Biconnected Component LeetCode Problems
- Binary Indexed Tree LeetCode Problems
- Binary Search LeetCode Problems
- Binary Search Tree LeetCode Problems
- Binary Tree LeetCode Problems
- Bit Manipulation LeetCode Problems
- Bitmask LeetCode Problems
- Brainteaser LeetCode Problems
- Breadth-First Search LeetCode Problems
- Bucket Sort LeetCode Problems
- Combinatorics LeetCode Problems
- Concurrency LeetCode Problems
- Counting LeetCode Problems
- Counting Sort LeetCode Problems
- Data Stream LeetCode Problems
- Database LeetCode Problems
- Depth-First Search LeetCode Problems
- Design LeetCode Problems