Practice Longest Mountain in Array
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
A mountain is a contiguous sequence of at least three values that strictly increases to one interior peak and then strictly decreases. Both the increasing and decreasing sections must contain a step. Given arr, return the longest mountain subarray’s length, or zero when none exists.
Source: Longest Mountain in Array on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
arr = [2,1,4,7,3,2,5]
Output
5
# Example 2
Input
arr = [2,2,2]
Output
0
Constraints
1 <= arr.length <= 10^4
0 <= arr[i] <= 10^4
Related LeetCode Problems
Practice more problems similar to Longest Mountain in Array.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.