Skip to content

Commit 2b4b54c

Browse files
committed
Styles corrected and added private constructor
1 parent a486ac0 commit 2b4b54c

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/main/java/com/thealgorithms/maths/UniformNumbers.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
public class UniformNumbers {
44

5+
// Private constructor to prevent instantiation of the utility class
6+
private UniformNumbers() {
7+
// Prevent instantiation
8+
}
9+
510
public static int uniformNumbers(int num) {
611
String numStr = Integer.toString(num);
712
int uniformCount = (numStr.length() - 1) * 9; // Count for digits less than current length
@@ -16,10 +21,10 @@ public static int uniformNumbers(int num) {
1621
return uniformCount;
1722
}
1823

19-
public static int countUniformIntegers(int A, int B) {
20-
if (B > A && (B > 0 && A > 0)) {
21-
return uniformNumbers(B) - uniformNumbers(A - 1);
22-
} else if (B == A) {
24+
public static int countUniformIntegers(int a, int b) {
25+
if (b > a && (b > 0 && a > 0)) {
26+
return uniformNumbers(b) - uniformNumbers(a - 1);
27+
} else if (b == a) {
2328
return 1;
2429
} else {
2530
return 0;

0 commit comments

Comments
 (0)