C++,Union Find,Two pointer
\n// custom comparator to sort based on weight\nbool comp(vector<int> &a,vector<int> &b){\n    if(a[2] == b[2]){\n        return a[1]<b[1];\n    }\n    return a
```\n// custom comparator to sort based on weight\nbool comp(vector<int> &a,vector<int> &b){\n    if(a[2] == b[2]){\n        return a[1]<b[1];\n    }\n    return a[2]<b[2];\n}\n\nclass Solution {\npublic:\n    \n    // Union Find data structure\n    \n    int parent[100005];\n    int sz[100005];\n    \n    void makeset(int v){\n        parent[v] = v;\n        sz[v] = 1;\n    }\n    int find(int v){\n        if(parent[v] == v) return v;\n        return parent[v] = find(parent[v]);\n    }\n    void Union(int x,int y){\n        x = find(x);\n        y = find(y);\n        if(x == y) return;\n        if(sz[x]>sz[y]) swap(x,y);\n        parent[y] = x;\n        sz[y]+=sz[x];\n    }\n    \n    vector<bool> distanceLimitedPathsExist(int n, vector<vector<int>>& edgeList, vector<vector<int>>& queries) {\n        \n        for(int i=0;i<n;i++) {\n            makeset(i);\n        }\n        int m = queries.size();\n        for(int i=0;i<queries.size();i++) {\n            queries[i].push_back(i);\n        }\n        \n        sort(queries.begin(),queries.end(),comp);\n        sort(edgeList.begin(),edgeList.end(),comp);\n        vector<bool> ans(queries.size(),false);\n        int i=0;\n        int j=0;\n        // two pointer\n        // building graph based on weights allowed by queries\n        while(j<m){\n            int wt = queries[j][2];\n            \n            while(i<edgeList.size() && edgeList[i][2]<wt){\n                int a = edgeList[i][0];\n                int b = edgeList[i][1];\n                Union(a,b);\n                i++;\n            }\n            if(find(queries[j][0]) == find(queries[j][1])){\n                ans[queries[j][3]] = 1;\n            }\n            j++;\n        }\n        return ans;\n    }\n};\n```
['Union Find', 'C', 'Sorting']