Given a distorted galaxy map represented by an array of celestial body masses, find the index of the first occurrence of the peak element, which is the maximum element in the array.
Explanation: Step-by-step: with input [23, 12, 45, 89, 23, 45, 12, 23, 45], we find the maximum element 89 at index 3, but since it appears multiple times, we need to find the first occurrence of the maximum element, which is 23 at index 0.
Explanation: Step-by-step: with input [42, 12, 45, 89, 42, 45, 12, 42, 45], we find the maximum element 89 at index 3, but since it appears multiple times, we need to find the first occurrence of the maximum element, which is 42 at index 0, but since 42 appears multiple times, we need to find the first occurrence of the maximum element, which is 42 at index 2.
Master coding challenges related to Arrays and solve the [Backup] Galaxy Navigation Peak problem optimally.
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak