Minimize Absolute Difference of Server Loads
Learn this problemProblem 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.
Given an array of n integers, of which represents loads caused by successive processes, return the minimum absolute difference of server loads.
Function
minAbsDifference(loads: int[]) → int
Complete the function minAbsDifference in the editor.
minAbsDifference has the following parameter:
int[] loads: an array of integers representing the loads
Returns
int: the minimum absolute difference of server loads
Examples
Example 1
loads = [1, 2, 3, 4, 5]return = 1Constraints
Unknown yet. If you happen to know about it, feel free to lmk! TYSM ~3~More Google problems
- Deduplicate Logs: Keep FirstONSITE INTERVIEW · Seen Jul 2026
- Deduplicate Logs: Keep LatestONSITE INTERVIEW · Seen Jul 2026
- Find a Template Across Binary-Tree LeavesONSITE INTERVIEW · Seen Jul 2026
- Maximum Programmer-Problem MatchingONSITE INTERVIEW · Seen Jul 2026
- Minimum Direction ViolationsONSITE INTERVIEW · Seen Jul 2026
- Stream Latest Log VersionsONSITE INTERVIEW · Seen Jul 2026
- Stream Unique Logs in Timestamp OrderONSITE INTERVIEW · Seen Jul 2026
- Top-K IP Addresses from File RecordsONSITE INTERVIEW · Seen Jul 2026