Java Solution (Union Find ~ 100%)
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n- Sort edge list by lim
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n- Sort edge list by limit, to have min edge with min limit with a higher rank\n- Build Union Find components with limits\n- Query UF to find connected componets based on limit\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public boolean[] distanceLimitedPathsExist(int n, int[][] edgeList, int[][] queries) {\n        var uf = new UF(n);\n        Arrays.sort(edgeList, Comparator.comparingInt(a -> a[2]));\n\n        for (var e : edgeList)\n            uf.union(e[0], e[1], e[2]);\n        \n        var answer = new boolean[queries.length];\n        for (var i = 0; i < queries.length; ++i)\n            answer[i] = uf.connected(queries[i][0], queries[i][1], queries[i][2]);\n\n        return answer;\n    }\n}\n\nclass UF {\n\n    private final int[] id, rank, limits;\n\n    UF(int N) {\n        this.id = new int[N];\n        this.rank = new int[N];\n        this.limits = new int[N];\n\n        for (var i = 0; i < N; ++i)\n            id[i] = i;\n    }\n\n    void union(int p, int q, int limit) {\n        var pId = find(p);\n        var qId = find(q);\n\n        if (pId == qId)\n            return;\n\n        if (rank[pId] < rank[qId]) {\n            id[pId] = qId;\n            limits[pId] = limit;\n        } else if (rank[pId] > rank[qId]) {\n            id[qId] = pId;\n            limits[qId] = limit;\n        } else {\n            id[qId] = pId;\n            limits[qId] = limit;\n            rank[pId]++;\n        }\n    }\n\n    boolean connected(int p, int q, int limit) {\n        return find(p, limit) == find(q, limit);\n    }\n\n    private int find(int p) {\n        while (p != id[p])\n            p = id[p];\n        \n        return p;\n    }\n\n    private int find(int p, int limit) {\n        while (p != id[p] && limits[p] < limit)\n            p = id[p];\n        \n        return p;\n    }\n}\n```
['Union Find', 'Java']