Skip to content

Commit da0db8a

Browse files
committed
Fix return values
1 parent 1c8bdd9 commit da0db8a

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/main/java/com/thealgorithms/backtracking/MColoring.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ static boolean isColoringPossible(ArrayList<Node> nodes, int n, int m) {
7676
// Keep track of the maximum number of colors used so far
7777
maxColors = Math.max(maxColors, Math.max(nodes.get(top).color, nodes.get(it).color));
7878

79-
// If the number of colors used exceeds the allowed limit M, return 0 (failure).
79+
// If the number of colors used exceeds the allowed limit M, return false.
8080
if (maxColors > m) {
81-
return 0;
81+
return false;
8282
}
8383

8484
// If the adjacent node hasn't been visited yet, mark it as visited and add it
@@ -91,7 +91,6 @@ static boolean isColoringPossible(ArrayList<Node> nodes, int n, int m) {
9191
}
9292
}
9393

94-
// Return 1 if it's possible to color the entire graph with M or fewer colors.
95-
return 1;
94+
return true; // Possible to color the entire graph with M or fewer colors.
9695
}
9796
}

0 commit comments

Comments
 (0)