Longest Mountain in Array

Medium · Arrays & Strings · about 20 minutes

Asked at Google, ByteDance, Amazon, Microsoft.

A mountain is a subarray of length at least 3 that strictly increases to a peak and then strictly decreases. Return the length of the longest mountain in arr, or 0 if there is none.

Related guides