Clean Java
after sort edge, query by weight, we constract UnionFind from small to large\nwe use extra query[3] to save original index(position)\n\nclass Solution {\n    pu
after sort edge, query by weight, we constract UnionFind from small to large\nwe use extra query[3] to save original index(position)\n```\nclass Solution {\n    public boolean[] distanceLimitedPathsExist(int n, int[][] edgeList, int[][] queries) {\n        int M = edgeList.length, N = queries.length;\n        DSU dsu = new DSU(n);\n        for (int i = 0; i < queries.length; i++) \n            queries[i] = new int[]{queries[i][0], queries[i][1], queries[i][2], i}; \n        Arrays.sort(queries, (a, b) -> a[2] - b[2]);\n        Arrays.sort(edgeList, (a, b) -> a[2] - b[2]);\n        boolean[] res = new boolean[N];\n        for (int i = 0, j = 0; i < N; i++) {\n            int[] query = queries[i];\n            while (j < M && edgeList[j][2] < queries[i][2])\n                dsu.union(edgeList[j][0], edgeList[j++][1]);\n            res[queries[i][3]] = dsu.find(queries[i][0]) == dsu.find(queries[i][1]);\n        }\n        return res;\n    }\n}\n\nclass DSU {\n    int[] parent;\n    public DSU(int N) {\n        this.parent = new int[N];\n        for (int i = 0; i < N; i++) parent[i] = i;\n    }\n    public int find(int x) {\n        if (parent[x] != x) parent[x] = find(parent[x]);\n        return parent[x];\n    }\n    public void union(int x, int y) {\n        parent[find(x)] = parent[find(y)];\n    }\n}\n\n```
[]