Ad
  • Custom User Avatar

    5 is not a peak, the next value is greater.

    shouldn't potential a peak value be greater than last and first el in order to actually be a peak?

    No, being a peak (or local maxima) depends on the surrounding values.

  • Custom User Avatar

    The first and last elements of the array will not be considered as peaks (in the context of a mathematical function, we don't know what is after and before and therefore, we don't know if it is a peak or not).

    3 is the only peak there. Use Question label next time.