Reported September 2024
Salesforcedynamic programming

Get Maximum Sum of Strengths

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

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

Salesforce asked this in September 2024, and it's a trap if you're not careful about state transitions. You have an array and need to maximize some sum based on "strengths," which usually means you're picking elements under constraints and computing a weighted result. The catch is that the problem often involves adjacent-element rules or mode-dependent selection. If you blank on the live OA, StealthCoder will read the exact constraints and feed you the DP state shape you need in real time.

Pattern and pitfall

Without the full problem text, the pattern is likely dynamic programming with careful state management. Most "max sum" problems on Salesforce assessments boil down to: can I pick this element given what I picked last, and what's the payoff. The trick is identifying what state you carry forward. It's rarely just 'sum so far.' You usually track the last element picked, whether you're in a 'strong' or 'weak' mode, or whether you just used a free pass. The common mistake is greedy selection instead of DP. Build a table where dp[i][state] represents the best sum up to index i in a given state. StealthCoder becomes your safety net if you blank on the state definition itself during the live assessment.

Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.

If this hits your live OA

You can drill Get Maximum Sum of Strengths 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 for the candidate who got the OA invite this morning and has 72 hours, not six months.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

Salesforce reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Get Maximum Sum of Strengths FAQ

Is this a greedy problem or DP?+

Almost certainly DP. Greedy fails because choosing the locally strongest element often blocks better future choices. You need to compare paths, which means memoization or tabulation. Build a table, not a one-pass loop.

What's the main trick Salesforce is testing?+

State machine thinking. The 'strength' is conditional on what you did before. You're not just summing elements; you're summing elements under a rule set that changes based on prior decisions. Nailing the state definition is 80% of the solution.

How do I even start if I blank in the OA?+

Read the constraint carefully: what rule prevents me from picking two things in a row, or picking the same mode twice. That rule becomes your DP state. Write out a few small examples by hand and see what state you'd need to track. Then build the table.

Is O(n) or O(n^2) the expected complexity?+

Likely O(n) or O(n log n) if sorting is involved. If you're doing O(n^2), check if you can reduce by fixing the state and iterating once. Salesforce expects clean complexity, not brute force.

Should I sort the array first?+

Depends on whether the problem cares about order. If 'strength' is order-agnostic and you're free to rearrange, sort by strength descending and use DP. If order is fixed, DP on the original order. Read the problem text very carefully.

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

OA at Salesforce?
Invisible during screen share
Get it