File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
src/main/java/com/thealgorithms/maths Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change 2
2
3
3
public class UniformNumbers {
4
4
5
+ // Private constructor to prevent instantiation of the utility class
6
+ private UniformNumbers () {
7
+ // Prevent instantiation
8
+ }
9
+
5
10
public static int uniformNumbers (int num ) {
6
11
String numStr = Integer .toString (num );
7
12
int uniformCount = (numStr .length () - 1 ) * 9 ; // Count for digits less than current length
@@ -16,10 +21,10 @@ public static int uniformNumbers(int num) {
16
21
return uniformCount ;
17
22
}
18
23
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 ) {
23
28
return 1 ;
24
29
} else {
25
30
return 0 ;
You can’t perform that action at this time.
0 commit comments