1724. Checking Existence of Edge Length Limited Paths II
An 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. Note that there may be multiple edges between two nodes, and the graph may not be connected.
Implement the DistanceLimitedPathsExist class:
- DistanceLimitedPathsExist(int n, int[][] edgeList) Initializes the class with an undirected graph.
- boolean query(int p, int q, int limit) Returns true if there exists a path from p to q such that each edge on the path has a distance strictly less than limit, and otherwise false.
c++
1 | class DistanceLimitedPathsExist { |