An undirected graph of n nodes is defined by edgeList, where edgeList[i] = [u_i, v_i, dis_i] denotes an edge between nodes u_i and v_i with distance dis_i. Note that there may be multiple edges between two nodes.
Given an array queries, where queries[j] = [p_j, q_j, limit_j], your task is to determine for each query whether there is a path between p_j and q_j such that each edge on the path has a distance strictly less than limit_j.
Return a boolean arrayanswer, where answer.length == queries.length and the jth value is true if there is such a path for the jth query, and false otherwise.
The query [0,1,2] is false because the only relevant edge has length 2, which is not strictly less than 2. The query [0,2,5] is true because 0 -> 1 -> 2 uses edges with lengths 2 and 4, both strictly less than 5.
For [0,4,14], the path 0 -> 1 -> 2 -> 3 -> 4 uses edge lengths 10, 5, 9, 13, all strictly less than 14. For [1,4,13], the edge with length 13 is not allowed because the limit is strict.
2 <= n <= 10^5
1 <= edgeList.length, queries.length <= 10^5
edgeList[i].length == 3
queries[j].length == 3
0 <= u_i, v_i, p_j, q_j <= n - 1
u_i != v_i
p_j != q_j
1 <= dis_i, limit_j <= 10^9
There may be multiple edges between two nodes.
Asked as a LeetCode-style graph/union-find problem in a software engineer phone screen.