Shortest Path
Shortest Path
Twenty-five questions on shortest-path algorithms, including Dijkstra's, Bellman-Ford, and Floyd-Warshall.
Cheapest Flights Within K Stops
mediumThere are n cities connected by some number of flights.
Digit Operations to Make Two Integers Equal
mediumYou are given two integers n and m that consist of the same number of digits.
Evaluate Division
mediumYou 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 equation Ai / Bi = values[i].
Find a Safe Walk Through a Grid
mediumYou are given an m x n binary matrix grid and an integer health.
Find Minimum Time to Reach Last Room I
mediumThere is a dungeon with n x m rooms arranged as a grid.
Find Minimum Time to Reach Last Room II
mediumThere is a dungeon with n x m rooms arranged as a grid.
Find the City With the Smallest Number of Neighbors at a Threshold Distance
mediumThere are n cities numbered from 0 to n-1.
Minimize the Maximum Edge Weight of Graph
mediumYou are given two integers, n and threshold, as well as a directed weighted graph of n nodes numbered from 0 to n - 1.
Minimum Cost of a Path With Special Roads
mediumYou are given an array start where start = [startX, startY] represents your initial position (startX, startY) in a 2D space.
Minimum Cost to Convert String I
mediumYou are given two 0-indexed strings source and target, both of length n and consisting of lowercase English letters.
Minimum Time to Reach Destination in Directed Graph
mediumYou are given an integer n and a directed graph with n nodes labeled from 0 to n - 1.
Minimum Time to Visit Disappearing Nodes
mediumThere is an undirected graph of n nodes.
Network Delay Time
mediumYou are given a network of n nodes, labeled from 1 to n.
Number of Restricted Paths From First to Last Node
mediumThere is an undirected weighted connected graph.
Number of Ways to Arrive at Destination
mediumYou are in a city that consists of n intersections numbered from 0 to n - 1 with bi-directional roads between some intersections.
Find Edges in Shortest Paths
hardYou are given an undirected weighted graph of n nodes numbered from 0 to n - 1.
Minimum Cost to Convert String II
hardYou are given two 0-indexed strings source and target, both of length n and consisting of lowercase English characters.
Minimum Cost to Make at Least One Valid Path in a Grid
hardGiven an m x n grid.
Minimum Obstacle Removal to Reach Corner
hardYou are given a 0-indexed 2D integer array grid of size m x n.
Minimum Time to Transport All Individuals
hardYou are given n individuals at a base camp who need to cross a river to reach a destination using a single boat.
Minimum Time to Visit a Cell In a Grid
hardYou are given a m x n matrix grid consisting of non-negative integers where grid[row][col] represents the minimum time required to be able to visit the cell (row, col), which...
Minimum Weighted Subgraph With the Required Paths
hardYou are given an integer n denoting the number of nodes of a weighted directed graph.
Modify Graph Edge Weights
hardYou 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, wi] indicates that there is...
Network Recovery Pathways
hardYou are given a directed acyclic graph of n nodes numbered from 0 to n − 1.
Number of Possible Sets of Closing Branches
hardThere is a company with n branches across the country, some of which are connected by roads.