Python, Union-Find
The key idea is to populate the union-find data structure as we answer queries ordered by the allowed edge cost, from smallest to biggest. Any connection under 
The key idea is to populate the union-find data structure as we answer queries ordered by the allowed edge cost, from smallest to biggest. Any connection under that cost is allowed to go into our structure.\n```\nclass UnionFind:\n\n    def __init__(self, size):\n        self.size = size\n        self.parents = list(range(size))\n        self.sizes = [0] * size\n    \n    def union(self, x, y):\n        rootx = self.find(x)\n        rooty = self.find(y)\n        if rootx == rooty: return\n        small, big = (rootx, rooty) if self.sizes[rootx] < self.sizes[rooty] else (rooty, rootx)\n        self.parents[small] = big\n    \n    def find(self, x):\n        if self.parents[x] != x:\n            self.parents[x] = self.find(self.parents[x])\n        return self.parents[x]\n\nclass Solution:\n    def distanceLimitedPathsExist(self, n: int, edgeList: List[List[int]], queries: List[List[int]]) -> List[bool]:\n        uf = UnionFind(n)\n        \n        edgeList.sort(key=lambda x: x[2])\n        answers = [None] * len(queries)\n        queries = [(l, s, d, i) for i, (s, d, l) in enumerate(queries)]\n        queries.sort(key=lambda x:x[0])\n        \n        eidx = 0\n        for limit, src, dest, q_idx in queries:\n            while eidx < len(edgeList) and edgeList[eidx][2] < limit:\n                uf.union(edgeList[eidx][0], edgeList[eidx][1])\n                eidx += 1\n            \n            answers[q_idx] = uf.find(src) == uf.find(dest)\n        \n        return answers\n```
['Union Find', 'Python', 'Python3']