mirror of
https://github.com/TheAlgorithms/Java.git
synced 2026-03-13 08:40:43 +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