MEDIUMasked at 4 companies

Longest Mountain in Array

A medium-tier problem at 41% community acceptance, tagged with Array, Two Pointers, Dynamic Programming. Reported in interviews at Faire and 3 others.

Founder's read

Longest Mountain in Array is a medium-difficulty array problem that shows up in assessments at Faire, SoFi, Databricks, and IBM. The acceptance rate sits around 41%, which tells you most candidates either miss the pattern entirely or code themselves into a corner with an inefficient scan. The trick isn't obvious: you need to recognize that a "mountain" is a specific shape (strictly increasing then strictly decreasing), and the naive approach of checking every possible subarray will time out. If this problem hits your live OA and you blank on the two-pointer or enumeration strategy, StealthCoder solves it in seconds, invisible to the proctor.

Companies asking
4
Difficulty
MEDIUM
Acceptance
41%

Companies that ask "Longest Mountain in Array"

If this hits your live OA

Longest Mountain in Array is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made by an Amazon engineer who watched the leaked-problem repo become an industry secret. He decided you should have it too.

Get StealthCoder
What this means

The core insight is that you can't just find any peak and expand outward. You need to validate that the left side is strictly increasing and the right side is strictly decreasing, and both must exist (no flat peaks, no single slopes). Most candidates start with dynamic programming or brute force checking all subarrays, which kills performance on large inputs. The efficient approach uses two pointers or enumeration: iterate through the array, and when you find a valid peak, expand left and right to find the boundaries of the mountain, then record its length. This runs in O(n) with a single pass or two clean passes. The topics here (Array, Two Pointers, Enumeration, Dynamic Programming) hint at multiple valid paths, but two pointers or enumeration is where speed lives. If you hit this on assessment day and the linear-time solution doesn't snap into focus, StealthCoder surfaces a working solution in real time.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Longest Mountain in Array recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made by an Amazon engineer who watched the leaked-problem repo become an industry secret. He decided you should have it too. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Longest Mountain in Array interview FAQ

What counts as a valid mountain in this problem?+

The array must have a strictly increasing part, a peak, and a strictly decreasing part. All three must exist. A single slope up or down, a flat plateau, or an array of length less than 3 does not qualify. The mountain must be contiguous.

Why does brute force fail here?+

Checking every possible subarray and validating each one is O(n squared) or worse. On large arrays, you'll time out. The problem demands a linear scan with smart peak detection and boundary expansion instead.

Is dynamic programming actually the right approach?+

DP can work if you track increasing and decreasing streak lengths at each index, but it's overkill. Two pointers or enumeration solves it cleaner and faster. DP is listed in the topics because it's a valid angle, not because it's optimal.

How do I know if this is still asked at these companies?+

Faire, SoFi, Databricks, and IBM have all reported this problem in their assessments. It's a solid medium-tier problem that tests pattern recognition and array iteration logic, so it stays relevant in rotation.

What's the biggest mistake candidates make?+

Forgetting that both strictly increasing and strictly decreasing segments must exist. Many code for a peak and expand, but don't validate that both slopes are non-empty and truly strict. That oversight causes wrong answers.

Want the actual problem statement? View "Longest Mountain in Array" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.