IBM OA Question | Give any different approach | 14/15 Test cases failed
Anonymous User
172

I got this question in IBM OA. I have sorted the arrays and tried to find the minmum sum. But 14/15 test cases failed. In another approach I used Heaps to solve this question. But this too failed. I am new lo this platform and apologise me if I sound silly. Please share any other ideas to solve this question.
Thank you!

Role Details:
Entry level Software Developer,
Bengaluru, Karnataka

Given a list of server capacities and a list of server loads, the goal is to redistribute the load across the servers to minimize the total resource consumption. The total resource consumption is calculated as the sum of serverCapacity[i] * serverLoad[i] for all servers.

Task:
Rearrange the serverLoad list to achieve the minimum possible total resource consumption. Return the rearranged serverLoad list.
Constraints:

  • 1 ≤ n ≤ 2 * 10^5
  • 1 ≤ serverCapacity[i], serverLoad[i] ≤ 10^9
    Example Input:
    serverCapacity = [1, 2, 3, 3, 3]
    serverLoad = [2, 2, 4, 5, 6]

Example Output:
[6, 5, 2, 2, 4]

Explanation:
By rearranging the serverLoad list as [6, 5, 2, 2, 4], the total resource consumption is minimized to 40.

Comments (0)