Reported August 2024
Googledynamic programming

Max Num of Moves with Same Result Sum

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's August OA included a problem about maximizing moves that produce the same result sum. You're staring at a state-space exploration problem where the trick isn't brute force, it's recognizing which sequences of operations converge to the same value. The ask is clean: given a set of moves, how many distinct sequences get you to the same target sum. This is a classic dynamic programming or memoization play, or possibly a greedy counting problem depending on the constraints. StealthCoder will catch the recurrence relation the moment it appears on your screen.

Pattern and pitfall

The core insight is that you're not just counting moves, you're tracking which combinations of moves yield identical sums. If moves are independent or commutative, order doesn't matter, and you're really counting multiset permutations or partitions. If order matters and some moves depend on prior state, you'll need memoization or DP to avoid recomputing the same subproblems. The pitfall is treating this as a greedy problem when it's actually combinatorial. The pattern likely involves either dynamic programming to count distinct paths to each sum, or mathematical combination logic if the problem has a structural symmetry. StealthCoder reads the constraint bounds and input shape, then flags whether you need recursion with memo or a DP table.

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 Max Num of Moves with Same Result 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 would have shipped this the night before his JPMorgan OA if he'd had it.

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. 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.

Max Num of Moves with Same Result Sum FAQ

Is this asking for permutations or combinations?+

The title says 'moves with same result sum,' not 'distinct orderings.' If two sequences of moves produce the same sum value, they count as one result. You're likely counting how many different move sequences yield the same final sum, which is a permutation problem if order matters in the computation.

Do I need to generate all possible sums first?+

Not necessarily. If you're asked for the maximum count of moves that produce a specific sum, you can use DP or memo to build up from smaller subproblems. Generating all sums upfront is wasteful. Instead, track the count of ways to reach each sum as you iterate through moves.

What's the common mistake on this problem?+

Assuming order doesn't matter and diving straight into combinatorics without verifying the problem statement. Also, forgetting to handle duplicate sums from different move sequences. Test with a small example first to clarify whether moves are independent.

How do I approach this in the first five minutes?+

Read carefully: what defines 'same result sum'. Is it a fixed target or any sum that appears multiple times. Sketch out a 2-3 move example by hand. Check if move order affects the result. This tells you whether to use DP, memoization, or counting logic.

Will this time out if I use recursion with memoization?+

Only if the state space is massive and your memo key is poorly chosen. If moves are small (under 20) or sums are bounded, memoization is fine. Watch out for exponential branching. If TLE happens, switch to bottom-up DP with a dictionary to store sum counts.

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