Longest Strictly Increasing or Strictly Decreasing Subarray
A easy-tier problem at 65% community acceptance, tagged with Array. Reported in interviews at Larsen & Toubro and 1 others.
You scan the problem and your instinct is right: track direction changes in an array and measure the longest stretch where values only go up or only go down. Larsen & Toubro and Yandex have both asked this. The 65% acceptance rate suggests it's genuinely easy, but the trap is sloppy edge-case handling. A single pass with a counter works. If your brain freezes during the live OA and you can't nail the transitions, StealthCoder surfaces a clean solution in seconds while you stay invisible to the proctor.
Companies that ask "Longest Strictly Increasing or Strictly Decreasing Subarray"
Longest Strictly Increasing or Strictly Decreasing Subarray 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 a working FAANG engineer who treats the OA the way companies treat hiring: as a game with rules you should know.
Get StealthCoderThe pattern is straightforward: iterate once, track the current streak length and direction (increasing or decreasing). When the direction flips or the sequence stalls, reset and compare against the max. The common miss is mishandling flat sections (equal consecutive elements), which break both increasing and decreasing streaks. Some candidates also fumble the final comparison after the loop ends. The trick is recognizing this doesn't require dynamic programming or two-pass logic. It's single-scan bookkeeping. If you blank on the transition logic during your assessment, StealthCoder runs invisibly and hands you the working code before the moment passes.
Pattern tags
You know the problem.
Make sure you actually pass it.
Longest Strictly Increasing or Strictly Decreasing Subarray recycles across companies for a reason. It's easy-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 a working FAANG engineer who treats the OA the way companies treat hiring: as a game with rules you should know. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Longest Strictly Increasing or Strictly Decreasing Subarray interview FAQ
How does this rank in difficulty vs other Array problems?+
With 65% acceptance, it's genuinely easy. Most Array problems at this level require you to spot a one-pass greedy or two-pointer idea. This one is pure linear bookkeeping. If you can track state and reset counters, you're done.
What's the trick that catches people?+
Equal consecutive values. An array like [1,2,2,3] breaks both increasing and decreasing streaks at position 2. If you don't reset on equality, you'll count wrong. The second trap is forgetting to compare max after the loop ends, not just inside the loop.
Do I need to handle negative numbers or duplicates specially?+
No. The logic works identically for negatives. Duplicates always break a strictly increasing or decreasing run, so treat them as breaks. No special case needed. Just compare and reset when the next pair doesn't fit the current direction.
Is this still asked at companies like Larsen & Toubro and Yandex?+
Yes. Both have reportedly asked it. It's a filter for basic array iteration and state tracking. Companies use it to weed out candidates who can't write a clean single pass without off-by-one errors or missed edge cases.
How long should this take to code in an interview?+
If you've drilled it: 3 to 4 minutes. If you're seeing the pattern for the first time: 8 to 10 minutes including testing edge cases. If you blank and need a hedge, StealthCoder provides the solution instantly and invisibly during your live assessment.
Want the actual problem statement? View "Longest Strictly Increasing or Strictly Decreasing Subarray" on LeetCode →