mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-27 06:23:08 +08:00
Add automatic linter (#4214)
This commit is contained in:
@ -33,11 +33,7 @@ class UpperBound implements SearchAlgorithm {
|
||||
int size = 100;
|
||||
int maxElement = 100000;
|
||||
|
||||
Integer[] integers = IntStream.generate(() -> r.nextInt(maxElement))
|
||||
.limit(size)
|
||||
.sorted()
|
||||
.boxed()
|
||||
.toArray(Integer[] ::new);
|
||||
Integer[] integers = IntStream.generate(() -> r.nextInt(maxElement)).limit(size).sorted().boxed().toArray(Integer[] ::new);
|
||||
|
||||
// The element for which the upper bound is to be found
|
||||
int val = integers[r.nextInt(size - 1)] + 1;
|
||||
@ -45,12 +41,10 @@ class UpperBound implements SearchAlgorithm {
|
||||
UpperBound search = new UpperBound();
|
||||
int atIndex = search.find(integers, val);
|
||||
|
||||
System.out.printf("Val: %d. Upper Bound Found %d at index %d. An array length %d%n", val,
|
||||
integers[atIndex], atIndex, size);
|
||||
System.out.printf("Val: %d. Upper Bound Found %d at index %d. An array length %d%n", val, integers[atIndex], atIndex, size);
|
||||
|
||||
boolean toCheck = integers[atIndex] > val || integers[size - 1] < val;
|
||||
System.out.printf(
|
||||
"Upper Bound found at an index: %d. Is greater or max element: %b%n", atIndex, toCheck);
|
||||
System.out.printf("Upper Bound found at an index: %d. Is greater or max element: %b%n", atIndex, toCheck);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user