Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Update FindMax to use Math.max for maximum calculation
Fix logic to find maximum value in the array.
  • Loading branch information
MuhammadMuneebMubashar authored Feb 9, 2026
commit 4e823d328772f184e876fc0faa721516c4474f31
4 changes: 1 addition & 3 deletions src/main/java/com/thealgorithms/maths/FindMax.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ public static int findMax(final int[] array) {
}
int max = array[0];
for (int i = 1; i < n; i++) {
if (array[i] > max) {
max = array[i];
}
max = Math.max(array[i] , array[i+1]);
}
return max;
}
Expand Down
Loading