Reported November 2024
Googlearray

Find Maximum Length Of Non-Decreasing Subarray

Reported by candidates from Google's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Google OA. Under 2s to a working solution.
Founder's read

Google asked this in November 2024 and it's a straightforward array scan that looks easy until you miss an edge case. You need to find the longest contiguous subarray where each element is greater than or equal to the previous one. It's not dynamic programming, not a complex data structure play. It's about tracking state cleanly as you iterate. If you blank on the approach during the OA, StealthCoder will spot the pattern instantly and feed you the solution while the proctor sees nothing.

Pattern and pitfall

The trick is simple: iterate once, track the current non-decreasing run length, update a max whenever the sequence breaks. When you hit an element smaller than the previous one, reset the current length to 1. The pitfall most candidates hit is forgetting to compare correctly (using > instead of >=), or resetting to 0 instead of 1 (which breaks the next run count). Edge cases: empty array, single element, all decreasing, all equal. Code is roughly 5-10 lines. This is a warm-up problem, not a hard algorithmic challenge. StealthCoder's value here is speed and accuracy under pressure, since the logic is easy to rush and fail.

If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.

If this hits your live OA

You can drill Find Maximum Length Of Non-Decreasing Subarray cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as max consecutive ones. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass Google's OA.

Google reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Find Maximum Length Of Non-Decreasing Subarray FAQ

Is this really a Google problem or are candidates exaggerating?+

It was reported in November 2024. Google uses warm-up problems to establish baseline coding speed. This fits that slot. Don't overthink it or you'll second-guess yourself.

Do I need to handle negative numbers or just positives?+

The problem doesn't specify. Assume the full integer range. Non-decreasing means each element >= the previous, so -5 to -3 is a valid run. Test both if you have time.

What if the whole array is non-decreasing?+

Return the array length. Your max should update all the way to the end. Make sure you're not resetting the count incorrectly after the loop finishes.

Is this a two-pointer or sliding window problem?+

No. It's a single pass with a counter. You track the current run length and the maximum run length seen so far. One pointer, one variable loop.

How much time should I spend on this in the real OA?+

5-10 minutes max if you know the pattern. Write, test on 2-3 cases, move on. If this is your warm-up problem, it's meant to build confidence, not consume time.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Google.

OA at Google?
Invisible during screen share
Get it