Reported July 2026
Salesforcearray

Update Pod Counts From Logs

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

The edge case that breaks a naive solution in this Salesforce OA, reported in July 2026, is the global update. Every log with podIndex -1 looks like a loop over all pods, and with enough logs that blows up. You're given pod counts and logs of [timestamp, podIndex, value]. Single-pod sets and floor-style raises interleave, and order matters. The timestamp is a decoy. Apply logs in the given order and you're fine. The trick is doing it without touching every pod each time. If you blank on the lazy approach during the live OA, StealthCoder runs invisibly as a safety net while you sort it out.

The problem

You are given the current pod counts for n microservices and a list of logs. Each log has three integers [timestamp, podIndex, value].
If podIndex != -1, update that 1-based pod index to value.
If podIndex == -1, update every pod whose current count is less than value to value.
The source notes that the timestamp is irrelevant for computing the final counts. Return the final pod counts after applying the logs in order.

Function
updatePodCounts(pods: int[], logs: int[][]) → int[]

Examples
Example 1
pods = [1,2,3,4]
logs = [[1,-1,3],[2,2,20],[1,-1,1]]
return = [3,20,3,4]
The first log raises pod counts below 3, giving [3,3,3,4]. The second log sets pod 2 to 20. The final global update to 1 changes nothing.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The naive approach loops all n pods for every -1 log, which is O(n * m). Instead, keep a single global floor value. A -1 log just sets floor = max(floor, value). A point update must beat that floor, so store the value plus the log index when it was set. The catch is ordering: a point update made before a later floor raise can be overwritten by it, and one made after must survive a lower floor. At the end, each pod's answer is max(its last assigned value, global floor). But a point set that is lower than the current floor still needs to be kept as that exact value, since later floors only raise it. The simplest correct way is to track the floor at the time of each point set and compare at the end. Pitfall: using 0-based indexing when podIndex is 1-based. If the logic gets tangled mid-assessment, StealthCoder is the hedge that gives you a clean version.

StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.

If this hits your live OA

You can drill Update Pod Counts From Logs 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. If you're reading this with an OA window open, you're who this was built for.

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. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Update Pod Counts From Logs FAQ

What's the trick in the Salesforce Update Pod Counts From Logs question?+

Don't loop over every pod on a -1 log. Keep a lazy global floor and only resolve it per pod at the end. Point updates overwrite the pod's value, and floor updates only raise it. That drops the work from O(n * m) to roughly O(n + m).

Does the timestamp matter?+

No. The problem says it's irrelevant for computing final counts. Apply the logs in the order given and ignore the first number in each log. Don't sort by timestamp, that's the trap if you assume it carries meaning.

What's the most common bug here?+

Off-by-one on podIndex, since it's 1-based. The second is mishandling a point set that's lower than the current floor. That set is a real assignment, and a later floor raise can still lift it. Trace example 1 by hand to check.

How hard is this really?+

Easy to medium. The brute force is obvious and passes small cases. The difficulty is spotting the lazy floor idea so large inputs don't time out. If you've seen range-assign-with-max problems, it clicks fast.

How do I prepare in 48 hours?+

Write the brute force first, then convert it. Practice the pattern of a lazy global value plus per-element last-write tracking. Test with logs that interleave floor raises and point sets in both orders, plus a case where the floor never exceeds any pod.

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