(self, x, y)
| 10 | return self.par[x] |
| 11 | |
| 12 | def union(self, x, y): |
| 13 | px, py = self.find(x), self.find(y) |
| 14 | if px == py: |
| 15 | return |
| 16 | if self.size[px] < self.size[py]: |
| 17 | self.par[px] = py |
| 18 | self.size[py] += self.size[px] |
| 19 | else: |
| 20 | self.par[py] = px |
| 21 | self.size[px] += self.size[py] |
| 22 | self.count -=1 |
| 23 | |
| 24 | class Solution: |
| 25 | def canTraverseAllPairs(self, nums: List[int]) -> bool: |
no test coverage detected