Problem · Array
Largest Element in an Array
Learn this problemProblem statement
You are given a non-empty integer array numbers. Return the largest value present in the array.
Function
largestElement(numbers: int[]) → intExamples
Example 1
numbers = [3,7,2,9,4]return = 99 is greater than every other value in the array.
Example 2
numbers = [-5,-2,-9]return = -2Among the negative values, -2 is the largest.
Example 3
numbers = [6]return = 6The only element is also the maximum.
Constraints
1 <= numbers.length <= 100000-10^9 <= numbers[i] <= 10^9