BackmediumArrays Uber

Astronomical Data Analysis Solution

Problem Statement

Given an array of radiation intensities, identify all indices of local maxima where the intensity is greater than or equal to its neighboring values. For edge cases, consider the intensity as a local maxima if it is greater than or equal to its single neighboring value.

Example 1
Input
[1, 2, 3, 2, 3, 3, 2, 1]
Output
[3, 5]

Explanation: Step-by-step: Given the input array [1, 2, 3, 2, 3, 3, 2, 1], we iterate through the array. At index 3, the value is 2, which is not greater than its neighboring values. However, at index 5, the value is 3, which is greater than or equal to its neighboring values. Therefore, the output should be [3, 5].

Example 2
Input
[1, 1, 1, 1, 1, 1, 1, 1]
Output
[]

Explanation: Step-by-step: Given the input array [1, 1, 1, 1, 1, 1, 1, 1], we iterate through the array. Since there are no local maxima, the output should be an empty array.

Constraints

  • The input array will have a minimum of 1 element and a maximum of 1000 elements.
  • All elements in the array will be integers between 1 and 1000.
Live Compiler
Loading...
Test Cases & Output
🔒 Sign up to run your code

🚀 Practice this problem

Run code, get AI hints & track streak

Sign Up Free