Given an array of integers representing a mountain sequence where elements strictly increase and then strictly decrease, find the index of the peak element.
Explanation: Step-by-step: with input [2, 1, 4, 7, 3, 2, 5], we first find the peak element by iterating through the array from left to right. We find that the element 7 is greater than its previous neighbor (4) and next neighbor (3), making it the peak element. Therefore, the output is 4.
Explanation: Step-by-step: with input [3, 2, 1, 4, 5, 2, 6, 7, 3, 2, 1], we first find the peak element by iterating through the array from left to right. We find that the element 7 is greater than its previous neighbor (6) and next neighbor (3), making it the peak element. Therefore, the output is 7.
Master coding challenges related to Arrays and solve the [Backup] Peak Element Finder in Mountain Array problem optimally.
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak