Sorting + Union Find | C++
\nclass Solution {\n    static bool cmp(vector<int> &a, vector<int> &b) {\n        return a[2] < b[2];\n    }\n    int find_prnt(int node, vector<int> &prnt) {\
```\nclass Solution {\n    static bool cmp(vector<int> &a, vector<int> &b) {\n        return a[2] < b[2];\n    }\n    int find_prnt(int node, vector<int> &prnt) {\n        if(node == prnt[node]) return node;\n        return prnt[node] = find_prnt(prnt[node], prnt);\n    }\n    void unionn(int u, int v, vector<int> &prnt, vector<int> &rank) {\n        int ulp_u = find_prnt(u, prnt), ulp_v = find_prnt(v, prnt);\n\n        if(rank[ulp_u] > rank[ulp_v]) prnt[ulp_v] = ulp_u; \n        else if(rank[ulp_u] < rank[ulp_v]) prnt[ulp_u] = ulp_v;\n        else {\n            prnt[ulp_v] = ulp_u;\n            rank[ulp_u]++;\n        }\n    }\npublic:\n    vector<bool> distanceLimitedPathsExist(int n, vector<vector<int>>& edgeList, vector<vector<int>>& queries) {\n        int m = queries.size(), p = 0;\n        for(int i=0; i<m; i++) queries[i].push_back(i);\n\n        sort(edgeList.begin(), edgeList.end(), cmp);\n        sort(queries.begin(), queries.end(), cmp);\n\n        vector<bool> ans(m);\n        vector<int> prnt(n), rank(n);\n        for(int i=0; i<n; i++) prnt[i] = i;\n\n        for(auto q : queries) {\n            while(p < edgeList.size() && edgeList[p][2] < q[2]) {\n                unionn(edgeList[p][0], edgeList[p][1], prnt, rank), p++;\n            }\n            ans[q[3]] = find_prnt(q[0], prnt) == find_prnt(q[1], prnt);\n        }\n        return ans;\n    }\n};\n```
['Union Find', 'Sorting', 'C++']