Reported November 2024
Google

Find Contiguous Subarray With Largest Min Plux Max

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 sent you this in November 2024, and the title alone tells you it's a subarray problem with a twist. You're not maximizing one thing, you're balancing two: the minimum and maximum within a window. This isn't a standard sliding-window or prefix-sum play. The trick is figuring out what metric actually matters when you're hunting for the subarray where min plus max reaches its peak. StealthCoder can spot the pattern and scaffold the solution if you freeze during the OA.

Pattern and pitfall

The core insight: you want a contiguous subarray where min(subarray) + max(subarray) is as large as possible. Naive approach checks all O(n^2) subarrays, tracking min and max for each, which works but may TLE on large inputs. The smarter angle is recognizing that for any subarray, the sum of its min and max is often dominated by the maximum value. This points toward a greedy or clever enumeration strategy, not DP. You might iterate through potential maximums and ask: what's the best minimum I can pair with it? Or scan subarrays smartly using a monotonic stack or deque to avoid redundant work. StealthCoder can inject the exact pattern once you've written the naive loop, turning it into a locked-in solution.

Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.

If this hits your live OA

You can drill Find Contiguous Subarray With Largest Min Plux Max 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. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

Google reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Find Contiguous Subarray With Largest Min Plux Max FAQ

Is this asking for the subarray itself or just the metric value?+

The input description doesn't specify. Assume you need the maximum value of (min + max) for any contiguous subarray. Be ready to return the subarray indices too if the OA feedback suggests it. Test against examples early.

Can I solve this in one pass?+

Unlikely for the optimal approach. You'll probably need two nested loops or a data structure like a stack/deque to track candidates efficiently. O(n^2) naive is your fallback if you're short on time.

Does the subarray have to be non-empty?+

Not stated, but assume yes. A single element subarray is valid: min and max are the same. Edge case: empty input should return 0 or null, not crash.

What if all numbers are negative?+

The metric is still min + max. If your array is [-5, -3, -8], the subarray [-3] gives 0 (or [-5, -3] gives -8). Edge cases matter. Test it.

How much time do I have to solve this live?+

Typical Google OA is 60-90 minutes for 2-3 problems. This is likely medium difficulty. Code the O(n^2) brute force first, verify on examples, then optimize if you see the pattern.

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