Make FindMin more efficient (#4389)
This commit is contained in:
parent
d3a32135dc
commit
c1476d796c
@ -34,10 +34,10 @@ public class FindMin {
|
||||
if (array.length == 0) {
|
||||
throw new IllegalArgumentException("array must be non-empty.");
|
||||
}
|
||||
int min = Integer.MAX_VALUE;
|
||||
for (final var value : array) {
|
||||
if (value < min) {
|
||||
min = value;
|
||||
int min = array[0];
|
||||
for (int i = 1; i < array.length; i++) {
|
||||
if (array[i] < min) {
|
||||
min = array[i];
|
||||
}
|
||||
}
|
||||
return min;
|
||||
|
Loading…
Reference in New Issue
Block a user