9. Maximum Array Element

Given an integer array a. Write a function int MaxArrayElement(int[] a) that returns the maximum element value in the array.
Example 1
Input: a = [1, 3, 2]
Output: 3
Explanation: 3 is the largest number in the array
Example 2
Input: a = [-1, -2, -3]
Output: -1
Explanation: -1 is greater than -2 and -3
Example 3
Input: a = [42]
Output: 42
Explanation: In a single-element array, that element is the maximum
arrayseasy
JavaScript
Loading...
Line 1, Char 1