Dsa
Binary Search
Medium
Mountain Peak Finder
Given a mountain array (an array that first increases and then decreases), write a function that finds the peak element of the mountain array using binary search. The peak element is defined as the element that is greater than its neighbors. You may assume the array has at least three elements.
Input Format:
A single line containing space-separated integers representing the mountain array.
Output Format:
The peak element from the mountain array.
Example:
Input:
1 3 8 12 4 2
Output:
12
Key concepts
binary_searcharrayspeak
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