ByteByteGo logo
menuProblems List

Local Maxima in Array

Medium

A local maxima is a value greater than both its immediate neighbors. Return any local maxima in an array. You may assume that an element is always considered to be strictly greater than a neighbor that is outside the array.

Example:

Example
Input: nums = [1, 4, 3, 2, 3]
Output: 1 # index 4 is also acceptable

Constraints:

  • No two adjacent elements in the array are equal.

You can practice coding exercises online by logging into bytebytego.com on your laptop.