JavaScript : With Explanation [100%, 100%] (Union Find)
Code\n\nvar distanceLimitedPathsExist = function(n, edgeList, queries) {\n    const uf = new UnionFind(n), ans = [];\n\n    // Create a list of index of queries
# Code\n```\nvar distanceLimitedPathsExist = function(n, edgeList, queries) {\n    const uf = new UnionFind(n), ans = [];\n\n    // Create a list of index of queries in incresing order of limit in each query\n    const order = Array(queries.length).fill().map((_, i) => i);\n    order.sort((a,b) => queries[a][2] - queries[b][2]);\n\n    // Sort edgeList in incresing order of distances\n    edgeList.sort((a,b) => a[2] - b[2]);\n\n    let index=0;\n    for(const i of order) {\n        const [p, q, limit] = queries[i];\n\n        // For each query, add all edges having distance less than limit\n        while(edgeList[index]?.[2] < limit){\n            uf.union(edgeList[index][0], edgeList[index][1]);\n            index++;\n        }\n\n        // If all edges dis is less than limit then below condition return true\n        ans[i] = uf.find(p) === uf.find(q);\n    }\n    return ans;\n};\n\n\n\n\n//////////////// Union Find Data Structure ////////////////\nclass UnionFind {\n    constructor(n) {\n        this.parent = Array(n).fill().map((_,i) => i);\n    }\n\n    find(i) {\n        if(this.parent[i] !== i) this.parent[i] = this.find(this.parent[i]);\n        return this.parent[i];\n    }\n    \n    union(i, j) {\n        this.parent[this.find(j)] = this.find(i);\n    }\n}\n```
['JavaScript']