FastPrepLargest Element in an Array
Problem · Array

Largest Element in an Array

Learn this problem
EasyDeloitte logoDeloitteNEW GRADOA

Problem statement

You are given a non-empty integer array numbers. Return the largest value present in the array.

Function

largestElement(numbers: int[]) → int

Examples

Example 1

numbers = [3,7,2,9,4]return = 9

9 is greater than every other value in the array.

Example 2

numbers = [-5,-2,-9]return = -2

Among the negative values, -2 is the largest.

Example 3

numbers = [6]return = 6

The only element is also the maximum.

Constraints

  • 1 <= numbers.length <= 100000
  • -10^9 <= numbers[i] <= 10^9

More Deloitte problems

drafts saved locally
public int largestElement(int[] numbers) {
    // Write your solution here.
}
numbers[3,7,2,9,4]
expected9
checking account