Concise and Clean 🧼🫧
\n\nclass Solution {\n    int p[];\n    int find(int a) { return p[a]==a? a: (p[a]=find(p[a])); }\n    void union(int a, int b) { p[find(b)]=p[find(a)]; }\n    
\n```\nclass Solution {\n    int p[];\n    int find(int a) { return p[a]==a? a: (p[a]=find(p[a])); }\n    void union(int a, int b) { p[find(b)]=p[find(a)]; }\n    public boolean[] distanceLimitedPathsExist(int n, int[][] edgeList, int[][] queries) {\n        p=new int[n]; for(int i=0;i<n;p[i]=i++);\n        Arrays.sort(edgeList, (a,b)->a[2]-b[2]);\n        for(int i=0;i<queries.length; queries[i]=new int[]{queries[i][0], queries[i][1], queries[i][2], i}, ++i); \n        Arrays.sort(queries, (a,b)->a[2]-b[2]);\n\n        boolean[] res=new boolean[queries.length];\n        int i=0;\n        for(int[] q: queries) {\n            while(i<edgeList.length && edgeList[i][2] < q[2]) union(edgeList[i][0], edgeList[i++][1]);\n            res[q[3]]=find(q[0])==find(q[1]);\n        }\n        return res;\n    }\n}\n```
['Java']