(union, i, num = union[i])
| 125 | const compress = (union, i, head) => (union[i] = head); |
| 126 | |
| 127 | const find = (union, i, num = union[i]) => { |
| 128 | const isEmpty = num === -1; |
| 129 | if (isEmpty) return i; |
| 130 | |
| 131 | const head = find(union, num); |
| 132 | |
| 133 | compress(union, i, head); |
| 134 | |
| 135 | return union[i]; |
| 136 | }; |