maxSorted
maxSorted(
x):number
Defined in: src/max_sorted.js:12
The maximum is the highest number in the array. With a sorted array, the last element in the array is always the largest, so this calculation can be done in one step, or constant time.
Parameters
Section titled “Parameters”number[]
input
Returns
Section titled “Returns”number
maximum value
Throws
Section titled “Throws”if x is empty
Example
Section titled “Example”maxSorted([-100, -10, 1, 2, 5]); // => 5