Skip to content

Commit 3fcf099

Browse files
committed
Fix PMD violation by utilizing isPowerOfTwo method
- Replace inline bit manipulation with isPowerOfTwo method call - Resolves PMD UnusedPrivateMethod violation - Maintains same validation logic and error handling - All tests continue to pass successfully
1 parent 2792325 commit 3fcf099

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/main/java/com/thealgorithms/others/MiniMaxAlgorithm.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ private boolean isPowerOfTwo(int n) {
115115
}
116116

117117
public void setScores(int[] scores) {
118-
if (scores.length <= 0 || (scores.length & (scores.length - 1)) != 0) {
118+
if (!isPowerOfTwo(scores.length)) {
119119
System.out.println("The number of scores must be a power of 2.");
120120
return;
121121
}

0 commit comments

Comments
 (0)