Algorithm · Meta · Hard
This prompt contains two independent tasks. Give a Java method for each one. Task A — find a peak position. You are given a non-empty array of integers nums. Call a position i a peak when its value is strictly larger than the element on its left and strictly larger than the element on its right. Everything outside the array counts as $$-\infty$$, which means the leftmost element is judged only against its right neighbor, and the rightmost element only against its left one.…
Checking your access…