Citadel Software Engineering Campus Assesment
Anonymous User
1411

A data processing pipeline consists of n services connected in a series where the output of the ith service serves as the input to the (i+ 1)th service. However, the processing units have varying latencies, and the throughput of the ith unit is represented by the array throughput[i] in messages per minute. The first service receives input through an API, and the nth service produces the final output.

Each service can be scaled up independently, with the cost of scaling up the ith service one unit equal to scaling_ cost[i]. After scaling up a service x times, it can process throughput[i]*(1 + x) messages per minute.

Given the arrays throughput and scaling_ cost, both of size n, and an integer budget representing the budget available, determine the optimal scaling configuration for the services such that the throughput generated by the nth service is maximized.

For instance, throughput = [4, 2, 7], scaling_cost = [3, 5, 6], and budget = 32.
To maximize the throughput of the final service, an optimal solution is:

Service indexscale fromscale toTimes scaledcost per scalingtotal cost
0412236
12104520
2714166

When these units are applied in series they generate a throughput of 10 units, the maximum possible throughput given the budget, hence the answer is 10

Comments (7)