Developers are optimizing their horizontal pod autoscaler for their microservices. There are n microservices, and the number of pods for the ith 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 thepth microservice is changed tox(1 <= p <= n).[2, -1, x]: All microservices whose number of pods is less thanxare changed tox.
Your task is to find the resulting number of pods for each microservice after processing all the logs.
pods = [2, 4, 1, 4] logs = [[1, 2, 30], [1, 3, 4], [2, -1, 10]] return = [10, 30, 10, 10]
Processing the logs:
- For
[1, 2, 30], the 2nd microservice's pod count is changed to30, so the pods become[2, 30, 1, 4]. - For
[1, 3, 4], the 3rd microservice's pod count is changed to4, so the pods become[2, 30, 4, 4]. - For
[2, -1, 10], all microservices with fewer than10pods are changed to10, so the pods become[10, 30, 10, 10].
Therefore, the answer is [10, 30, 10, 10].
Source note (June 28, 2026): The original post did not include the output for this example. FastPrep worked it out from the problem statement and the given input. If you have the original output or notice something wrong, please let us know and we'll fix it. If we find the original source later, we'll come back and update this too. 🐿️
- Minimize Total Input Cost (for LTMS)Seen Jun 2026
- Count Prime StringsONSITE INTERVIEW · Seen Jun 2026
- Minimum Removals to Balance ArrayOA · Seen May 2026
- Key Teams in TreeOA · Seen Mar 2026
- System Energy ReductionOA · Seen Mar 2026
- Update Logs by Symmetric XOROA · Seen Mar 2026
- Count Palindromic Concatenation PairsOA · Seen Mar 2026
- Collect Opportunity Data in a TreeOA · Seen Feb 2026
public int[] getFinalPods(int[] pods, int[][] logs) {
// write your code here
}