Given a list of distinct asteroid sizes in a galaxy, find all asteroid sizes that are larger than their neighboring asteroids.
Explanation: Step-by-step: Given the input [50, 20, 30, 40, 50], we first identify the asteroid sizes that are larger than their neighboring asteroids. In this case, 50 is larger than its neighbors 20, 30, and 40. Therefore, the output is [50].
Explanation: Step-by-step: Given the input [7, 5, 9, 8, 7], we first identify the asteroid sizes that are larger than their neighboring asteroids. In this case, 7 is larger than its neighbors 5 and 7, 9 is larger than its neighbors 5 and 8, and 8 is larger than its neighbors 5 and 7. Therefore, the output is [7, 9, 8].
Master coding challenges related to Arrays and solve the [Backup] Galaxy Anomaly Detector problem optimally.
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak