Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
The lowest possible difference can be obtained when the sum of the first n elements in the resultant array is minimum, and the sum of the next n elements is maximum.
For every index i, think about how you can find the minimum possible sum of n elements with indices lesser or equal to i, if possible.
Similarly, for every index i, try to find the maximum possible sum of n elements with indices greater or equal to i, if possible.
Now for all indices, check if we can consider it as the partitioning index and hence find the answer.