FastPrepUpdate Pod Counts From Logs
Problems/Update Pod Counts From Logs

Update Pod Counts From Logs

Salesforce logoSalesforce● HardOA

Updated Nov 2026

QuestionFunctionExamples

Problem 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 to value.
  • If podIndex == -1, update every pod whose current count is less than value to value.

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 Online Assessment questions

  • Count Subarrays With Product Equal to KOA · Seen Dec 2026
  • Get Minimum TimeOA · Seen Nov 2026
  • Minimum No-Repeat Segments After One Character RemovalOA · Seen Nov 2026
  • Get Message StatusOA · Seen Nov 2026
  • Minimum Unique-Character Segments After DeletionOA · Seen Sep 2026
  • Run-Length String CompressionOA · Seen Sep 2026
  • Maximum Requests in WindowOA · Seen Sep 2026
  • Final Pod Counts After LogsOA · Seen Aug 2026
  • Minimum Removals to Balance ArrayOA · Seen Aug 2026
  • Is This Date a Weekend?OA · Seen Aug 2026

Similar questions at other companies

  • Repeated Maximum and Minimum Request ScoreAmazon · OA
  • Find Total WeightJP Morgan Chase · OAJP Morgan Chase interview questions
  • Apply Binary State OperationsZipRecruiter · OAZipRecruiter interview questions
  • Meeting Rooms III: Most Booked RoomGoogle · ONSITE INTERVIEWGoogle interview questions
  • Meeting Rooms IIIBloomberg LP · PHONE SCREENBloomberg LP interview questions
  • Order Matching on ExecuteSquarepoint Capital · ONSITE INTERVIEWSquarepoint Capital interview questions
  • Shortest-Job-First Process SchedulingByteDance · PHONE SCREENByteDance interview questions
  • Dynamic Batch Completion TimesAmbience Healthcare · PHONE SCREEN
  • Insert into a Min-HeapGoldman Sachs · ONSITE INTERVIEWGoldman Sachs interview questions
  • Automation Pipeline, Part 3: Stage DurationPlaid · PHONE SCREENPlaid interview questions

Salesforce interview experiences

  • Salesforce Infrastructure SWE OA and Onsite: 1 Experience
  • Salesforce Experienced Backend SWE First Round: 1 Experience
All Salesforce interview questionsSee Salesforce hiring insights
Saved
class Solution {
    public int[] updatePodCounts(int[] pods, int[][] logs) {
      // write your code here
    }
}
Checking account…