(int x)
| 32 | } |
| 33 | |
| 34 | public int find(int x) { |
| 35 | if (x == this.parent[x]) { |
| 36 | return x; |
| 37 | } |
| 38 | // Path compression. |
| 39 | this.parent[x] = find(this.parent[x]); |
| 40 | return this.parent[x]; |
| 41 | } |
| 42 | |
| 43 | public int getSize(int x) { |
| 44 | return this.size[find(x)]; |