Minimize Absolute Difference of Server Loads
Problem statement
There are some processes that need to be executed. Amount of a load that process causes on a server that runs it, is being represented by a single integer. Total load caused on a server is the sum of the loads of all the processes that run on that server. You have at your disposal two servers, on which mentioned processes can be run. Your goal is to distribute given processes between those two servers in the way that, absolute difference of their loads will be minimized.
Examples
Example 1
loads = [1, 2, 3, 4, 5]return = 1We can distribute the processes with loads [1, 2, 4] to the first server and [3, 5] to the second one, so that their total loads will be 7 and 8, respectively, and the difference of their loads will be equal to 1.
Unlock this recently reported problem
FastPrep Pro gives you full access to interview problems reported within the last week.
- Full problem statement and constraints
- Worked examples, explained
- Guided hints and editorial
- Run your code on real test cases
$99 billed yearly — or $19 month-to-month. Cancel anytime.