We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6ecbd41 commit f6c204dCopy full SHA for f6c204d
src/main/java/com/thealgorithms/graph/DisjointSet.java
@@ -59,15 +59,13 @@ public class DisjointSet {
59
* @throws IllegalArgumentException if size is negative
60
*/
61
public DisjointSet(int size) {
62
- if (size < 0) {
+ if (size < 0)
63
throw new IllegalArgumentException("Size must be non-negative");
64
- }
65
this.size = size;
66
this.numSets = size;
67
parent = new int[size];
68
rank = new int[size];
69
70
- // Initialize each element as its own set
71
for (int i = 0; i < size; i++) {
72
parent[i] = i;
73
rank[i] = 0;
0 commit comments