MCPcopy Create free account
hub / github.com/neetcode-gh/leetcode / find

Method find

java/0684-redundant-connection.java:19–22  ·  view source on GitHub ↗
(int x)

Source from the content-addressed store, hash-verified

17 }
18
19 public int find(int x) {
20 if (x == parent[x - 1]) return x;
21 return find(parent[x - 1]);
22 }
23
24 public void union(int x, int y) {
25 parent[find(y) - 1] = find(x);

Callers 2

unionMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected