Peak Index in Mountain Array Problem
Peak Index in Mountain Array Problem — ExecCode Easy DSA Practice
Solve the Peak Index in Mountain Array problem on ExecCode. Free online easy DSA practice in Arrays / Binary Search. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Description You are given an integer mountain array arr of length n where the values increase to a peak element and then decrease. Your task is to compute the answer and return the index of the peak element.
Examples
Input {"nums": [0, 1, 2, 1, 0]}; Output 2. Input {"nums": [0, 2, 1]}; Output 1. Input {"nums": [1, 2, 3, 4, 5, 3, 1]}; Output 4
Constraints
3 <= arr.length <= 10^5 0 <= arr[i] <= 10^6 arr is guaranteed to be a mountain array.
Practice Peak Index in Mountain Array free on ExecCode. Browse DSA problems, topic map, and placement guides.