Longest Mountain — Solution & Editorial
Scan for peaks (ai−1 < ai > ai+1); expand left while strictly rising and right while strictly falling; skip the whole mountain afterward for O(N).
Complexity: O(N)
Scan for peaks (ai−1 < ai > ai+1); expand left while strictly rising and right while strictly falling; skip the whole mountain afterward for O(N).
Complexity: O(N)