Python | Union Find | Simple and Easy
```\nclass Solution:\n    def distanceLimitedPathsExist(self, n: int, edgeList: List[List[int]], queries: List[List[int]]) -> List[bool]:\n        def find(v):\
```\nclass Solution:\n    def distanceLimitedPathsExist(self, n: int, edgeList: List[List[int]], queries: List[List[int]]) -> List[bool]:\n        def find(v):\n            if parent[v] != v:\n                parent[v] = find(parent[v])\n            return parent[v]\n        def union(v, w):\n            parent[find(v)] = find(w)\n        edgeList.sort(key = lambda e: e[2])\n        queries = sorted(((v,w,limit,i) for i, (v, w, limit) in enumerate(queries)), key = lambda e:e[2])\n        parent = [i for i in range(n)]\n        j = 0\n        res = [0]*len(queries)\n        for v,w,limit,i in queries:\n            while j < len(edgeList) and edgeList[j][2] < limit:\n                p, q, _ = edgeList[j]\n                union(p,q)\n                j += 1\n            res[i] = find(v) == find(w)\n        return res
['Union Find', 'Python']