Dsa
Binary Search
Warm-up
Find Peak Element
A peak element is an element that is greater than or equal to its neighbors. Given an array of integers, find a peak element. A peak element could be any of the edge elements.
Input Format:
- The first line contains an integer n, the number of elements in the array.
- The second line contains n space-separated integers.
Output Format:
- Print the peak element.
Example:
Input:
5
1 3 20 4 1
Output:
20
Key concepts
binary_searcharrayssearch
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