mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-12-19 07:00:35 +08:00
Fix absolute max bug (#6144)
This commit is contained in:
@@ -17,7 +17,7 @@ public final class AbsoluteMax {
|
||||
}
|
||||
int absMax = numbers[0];
|
||||
for (int i = 1; i < numbers.length; i++) {
|
||||
if (Math.abs(numbers[i]) > Math.abs(absMax)) {
|
||||
if (Math.abs(numbers[i]) > Math.abs(absMax) || (Math.abs(numbers[i]) == Math.abs(absMax) && numbers[i] > absMax)) {
|
||||
absMax = numbers[i];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user