

load = {10, 11, 7, 5}
In the given example, the total load can be divided such that the first server handles processes 1st and 3rd and the second server handles processes 2nd and 4th. Hence the absolute difference is abs((10 + 7) - (11 + 5)) = 1.
So the final answer is 1.
The first line contains a single integer ‘T’ denoting the number of test cases, then each test case follows:
The first line of each test case contains a single integer ‘N’ denoting the total number of processes.
The next N lines each contain “load[i]” denoting the load by each process.
For each test case, print a single integer “ans” denoting the minimum absolute difference of the total load on the two servers.
Output for each test case will be printed in a separate line.
You are not required to print anything; it has already been taken care of. Just implement the function.
1 <= T <= 10
1 <= N <= 100
1 <= load[i] <= 50
Time limit: 1 sec
In this approach, we will check for every possible subsequence which can be formed by the list of loads and take an integer “answer” in which we will store the minimum possible load and return the “answer” after checking every possible subsequence.
The steps are as follows:
In this approach, we will call a recursive function for an index and we will generate two cases:
And return the minimum possible difference from the recursion.
The steps are as follows:
This approach is similar to the previous approach, the only difference is we are storing the minimum cost for all subarrays and use the precomputed values when required.
The steps are as follows:
In this approach we will take a 2D array “dp”. “dp[i][j]” will store whether it is possible to have the total number of processes ‘j’ in 1st server, taking the “ith” process.
The steps are as follows: