Very simple solution with explanations
Using DSU, we can add edges from small weight to large weight, and query from small limit to large limit. \n\nTime complexity:O(E log E) + O(Q log Q)\nSpace com
Using DSU, we can add edges from small weight to large weight, and query from small limit to large limit. \n\nTime complexity:` O(E log E) + O(Q log Q)`\nSpace complexity: `O(n)`\n\n```\n    class DSU {\n        vector<int> parent, rank;\n        public:\n        DSU(int n) {\n            parent.resize(n);\n            for (int x = 0; x < n; x++) {\n                parent[x] = x;\n            }\n            rank.resize(n);\n        }\n        int find(int x) {\n            int p = parent[x];\n            if (p == x) return x;\n            return parent[x] = find(p);\n        }\n        void unions(int x, int y) {\n            x = find(x); y = find(y);\n            if (x == y) return;\n            \n            if (rank[x] == rank[y]) rank[x]++;\n            else if (rank[x] < rank[y]) swap(x, y);\n            parent[y] = x;\n        }\n    };\n    \npublic:\n    vector<bool> distanceLimitedPathsExist(int n, vector<vector<int>>& edgeList, vector<vector<int>>& queries) {\n        auto cmp = [&](vector<int> &a, vector<int> &b) {\n          return a[2] < b[2];  \n        };\n        sort(edgeList.begin(), edgeList.end(), cmp); // sort by weight\n        \n        for (int i = 0; i < queries.size(); i++) queries[i].push_back(i); // record index\n        sort(queries.begin(), queries.end(), cmp);  // sort by limit\n        \n        DSU dsu(n);\n        vector<bool> res(queries.size());\n        int i = 0;\n        for (auto &q : queries) {\n            while(i < edgeList.size() && edgeList[i][2] < q[2]) { // only take edges with smaller weight than limit\n                dsu.unions(edgeList[i][0], edgeList[i][1]);\n                i++;\n            }\n            res[q[3]] = dsu.find(q[0]) == dsu.find(q[1]);\n        }\n        return res;\n    }
[]