Longest Mountain in Array Problem
Longest Mountain in Array Problem — ExecCode Easy DSA Practice
Solve the Longest Mountain in Array problem on ExecCode. Free online easy DSA practice in Two Pointers. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Description You are given an integer array arr, return the length of the longest subarray, which is a mountain. Your task is to compute the required answer and return 0 if there is no mountain subarray. You may recall that an array arr is a mountain array if and only if: - arr.length >= 3 - There exists some index i (0-indexed) with `0 arr[i + 1] > ...
Examples
Input {"nums": [2, 1, 4, 7, 3, 2, 5]}; Output 5
Constraints
1 <= arr.length <= 10^4 0 <= arr[i] <= 10^4
Practice Longest Mountain in Array free on ExecCode. Browse DSA problems, topic map, and placement guides.