C++ concise sort then union find
```\nclass Solution {\npublic:\n    vector distanceLimitedPathsExist(int n, vector>& edgeList, vector>& queries) {\n        vroot.resize(n);\n        for(int i=
```\nclass Solution {\npublic:\n    vector<bool> distanceLimitedPathsExist(int n, vector<vector<int>>& edgeList, vector<vector<int>>& queries) {\n        vroot.resize(n);\n        for(int i=0;i<n;i++) vroot[i] = i;\n        for(int i=0;i<queries.size();i++) queries[i].push_back(i);\n        sort(queries.begin(), queries.end(), [](auto& v1, auto& v2){return v1[2] < v2[2];});\n        sort(edgeList.begin(), edgeList.end(), [](auto& v1, auto& v2) {return v1[2] < v2[2];});\n        \n        vector<bool> res(queries.size());\n        auto it = edgeList.begin(), end = edgeList.end();\n        for(auto& v:queries){\n            int p = v[0], q = v[1], limit = v[2], i = v[3];\n            while(it != end && (*it)[2] < limit){\n                connect((*it)[0], (*it)[1]);\n                ++it;\n            }\n            res[i] = isConnect(p, q);\n        }\n        return res;\n    }\n    \n    void connect(int i, int j){\n        auto ri = root(i), rj = root(j);\n        vroot[ri] = rj;\n    }\n    \n    bool isConnect(int i, int j){\n        return root(i) == root(j);\n    }\n    \n    int root(int i){\n        if(vroot[i] != i) vroot[i] = root(vroot[i]);\n        return vroot[i];\n    }\n    \n    vector<int> vroot;\n};
[]