Skip to main content

Accenture

Accenture OA-16 2024

Problem Description

You are on a hiking trail represented by an array A of length N, where the trail initially ascends and then descends, forming a single peak. Your task is to find and return an integer value representing the elevation of the summit.

Input Format:

  • Input1: An integer array A
  • Input2: An integer value N denoting the size of A

Output Format:

Return an integer value representing the elevation of the summit.

Constraints:

  • 3≤N≤10^6: The length of the array A.
  • 1≤A[i]≤10^6: Each element in array A represents the elevation at that point on the trail.

Example

Sample Input:

A = [1, 2, 3, 4, 5, 4, 3, 2, 1]
N = 9

Sample Output:

5

Explanation:
In the given array, the peak point is 5. Therefore, the elevation of the summit is 5.