An undirected graph has n vertices numbered 0 to n - 1. edgeList[i] = [u, v, length] is an edge, and several edges may join the same pair. Each query is [p, q, limit]: is there a path from p to q in which every edge is strictly shorter than limit?
Write distanceLimitedPathsExist(n, edgeList, queries) returning an array of booleans, one per query, in the order the queries were given.
- A query with
p === q is always true - Do not mutate
edgeList or queries - With tens of thousands of queries a fresh search per query is too slow