Get Maximum Sum
Reported by candidates from Snowflake's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
You're taking Snowflake's assessment in the next 48 hours and this is one of the problems floating around from July 2024 candidates. 'Get Maximum Sum' sounds simple until you realize it's testing whether you can spot the optimal subarray or subsequence pattern. Most candidates either brute force it and hit time limits, or miss the trick that turns a quadratic solution into linear. StealthCoder sits ready as your safety net if the pattern doesn't click under pressure, feeding you the approach the moment you need it.
Pattern and pitfall
This problem almost certainly asks you to maximize a sum across an array, constrained either by contiguity (maximum subarray, a Kadane's algorithm question) or by some structural rule (no adjacent elements, alternating selections, or dynamic constraints). The trap is overthinking it. If it's contiguous, Kadane's is O(n) and elegant. If it's non-contiguous (like house robber variants), you track two states per position: take it or skip it. The common failure mode is trying to greedy-select the largest values without respecting the constraint. When you sit down live and the constraint hits you, StealthCoder can immediately surface whether this is a sliding-window max, DP state machine, or prefix-sum play.
If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.
You can drill Get Maximum Sum 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 passed his OA cold and still thinks the filter is broken.
Get StealthCoderRelated leaked OAs
This OA pattern shows up on LeetCode as maximum subarray. If you have time before the OA, drill that.
You've seen the question.
Make sure you actually pass Snowflake's OA.
Snowflake reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Get Maximum Sum FAQ
Is 'Get Maximum Sum' just Kadane's algorithm?+
Probably, but not guaranteed. If the problem allows non-contiguous picks, it's a DP variant (like house robber). Read the constraint carefully. Contiguous = Kadane's O(n). Non-contiguous with rules = DP with 2-3 states. The difference matters for your approach.
What's the most common pitfall on this problem?+
Greedy fails here. Picking the largest value at each step doesn't guarantee the max sum because of the constraint (contiguity, adjacency rule, whatever it is). Always trace through an example where greedy picks wrong before you code.
Can I solve this in one pass?+
If it's Kadane's or a straightforward DP, yes. One loop, O(n) time, O(1) or O(n) space depending on variant. If you're writing nested loops, you've misread the constraint. Step back and re-read the problem.
How do I prepare for 'Get Maximum Sum' in 24 hours?+
Know Kadane's cold. Know the house robber DP pattern (take/skip state). Trace both on a small example by hand. Then read the Snowflake problem carefully and map it to one of those two. Don't memorize variants, understand the state machine.
Will this fail on edge cases like empty arrays or single elements?+
Yes, if you don't handle them. An empty array should return 0 or error per the spec. A single element is the answer. Always check these before submitting, especially under time pressure.