Commit d818eda
committed
feat: Implement max and maxRange methods to find maximum element in full or partial array
🧠 Logic:
- `maxRange(arr, start, end)` finds the maximum value in a subarray from index `start` to `end`.
- Handles edge cases: null array or invalid range (`start > end`) return -1.
- `max(arr)` finds the maximum element in the entire array.
- Returns -1 if array is empty.
- Both methods use linear scan to compare and update max value.
Signed-off-by: Somesh diwan <[email protected]>1 parent d716764 commit d818eda
1 file changed
+1
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | | - | |
10 | 9 | | |
11 | 10 | | |
12 | 11 | | |
13 | | - | |
14 | 12 | | |
15 | 13 | | |
16 | 14 | | |
| |||
0 commit comments