Problem · Array
Update Pod Counts From Logs
Learn this problemProblem statement
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 tovalue. - If
podIndex == -1, update every pod whose current count is less thanvaluetovalue.
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.
More Salesforce problems
- Minimize Total Input Cost (for LTMS)Seen Jun 2026
- Count Prime StringsONSITE INTERVIEW · Seen Jun 2026
- Final Pod Counts After LogsOA · Seen May 2026
- ATM Queue Exit OrderPHONE SCREEN · Seen May 2026
- Good Ways to Split an ArrayPHONE SCREEN · Seen May 2026
- Generate Seen Binary StringsOA · Seen May 2026
- Minimum Removals to Balance ArrayOA · Seen May 2026
- Key Teams in TreeOA · Seen Mar 2026