Dsa
Binary Search
Medium
Find Peak Element in an Unimodal Array
A peak element in an array is an element which is greater than or equal to its neighbors. Given a unimodal array (strictly increasing then strictly decreasing), write a program to find a peak element using binary search.
Input Format:
- The first line contains an integer n (n >= 3), the size of the array.
- The second line contains n integers, representing the unimodal array.
Output Format:
- Print any peak element.
Example:
Input:
5
1 3 5 4 2
Output:
5
Key concepts
binary_searcharrays
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now