Fundamentals/Find Maximum
← PrevNext →
Given a non-empty array of integers, return the maximum value in the array.
Input
nums: non-empty array of integers
Output
The largest integer in nums.
Examples
Example 1
Inputnums = [3, 1, 4, 1, 5, 9]
Output9
Example 2
Inputnums = [-10, -3, -7, -1]
Output-1
Constraints
nums contains at least one element.
Values may be negative.