Reported June 2026
Salesforcearray

Final Pod Counts After 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

Salesforce reported this one in June 2026, and the catch is in the sizes: n services and m logs means a naive loop that applies every floor event to every service is O(n*m), which dies on big inputs. If you've got an OA coming, this is the shape to expect. It's an array problem with a lazy-update trick hiding inside. Once you see it, the code is about fifteen lines. If you blank on the live assessment, StealthCoder runs invisibly on your desktop as a safety net and hands you the approach while you keep typing.

The problem

Developers are optimizing their horizontal pod autoscaler for their microservices. There are n microservices, and the number of pods for the iᵗʰ microservice is pods[i].
According to traffic patterns, the number of pods for a service can increase or decrease. Additionally, at specific times when there is expected traffic, all services with fewer than x pods are assigned x pods.
There is an event log of size m, described as a 2D array logs where logs[i] is an array of integers of size 3. The logs have the following interpretations:
[1, p, x]: The number of pods of the pᵗʰ microservice is changed to x (1 ≤ p ≤ n)
[2, -1, x]: All microservices whose number of pods is less than x are changed to x
Your task is to find the resulting number of pods for each microservice after processing all the logs.

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

Examples
Example 1
pods = [2, 4, 1, 4]
logs = [[1, 2, 30], [1, 3, 4], [2, -1, 10]]
return = [10, 30, 10, 10]
n = 4
pods = [2, 4, 1, 4]
m = 3
logs = [[1, 2, 30], [1, 3, 4], [2, -1, 10]]
Current Number of PodsLogResulting Pods
[2, 4, 1, 4][1, 2, 30] 2nd member's pod count is changed to 30.[2, 30, 1, 4]

Reported by candidates. Source: FastPrep

Pattern and pitfall

Don't apply type 2 logs one by one. A floor event only matters relative to what happens after it. Process the logs in order, but track the latest explicit set per service (value and log index), and record the floor values. The final answer for service i is max(last set value, the largest floor that came after that set). Build a suffix maximum over floors by log index, so each lookup is O(1). Services never set by a type 1 log use their original pods value and the max floor over all logs. Total cost is O(n+m). The common pitfall is taking the global max floor for every service, which wrongly overrides a later set that was lower than an earlier floor. Another is forgetting that a set can lower a count below a previous floor. Check example 1: the floor 10 comes after both sets, so 30 stays and 4 becomes 10.

If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.

If this hits your live OA

You can drill Final Pod Counts After 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. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken.

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. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Final Pod Counts After Logs FAQ

What's the trick in Final Pod Counts After Logs?+

Avoid touching every service on each floor event. Keep a suffix maximum of floor values by log position, then for each service take the max of its last set value and the biggest floor that occurred after that set. One pass over logs, one pass over services.

How hard is this problem really?+

Medium at most. The logic is simple, but the brute force looks natural and times out. If you spot that a floor is just a max operation that can be deferred, the solution is short and clean.

Why does order of logs matter here?+

A floor only affects values that exist when it fires. A later set overwrites an earlier floor, and a later floor can lift an earlier set. So you need to know which floors came after each service's last set, not just the global max.

What edge cases should I test?+

A service never set by any log, a floor lower than every current value, a set to a value below an earlier floor, and multiple sets on the same service. Also logs with only floor events, where the answer is max(original, biggest floor).

How do I prepare for this in 48 hours?+

Write the suffix max approach once from scratch and run example 1 by hand. Then do a couple of similar lazy-update array problems. The goal is recognizing that a bulk update can be deferred and resolved at the end.

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