Hard · Dynamic Programming

Partition Array Into Two Arrays to Minimize Sum Difference

Given an integer array nums of length 2n, split it into two arrays of exactly n elements each and return the minimum possible absolute difference between their sums.

Examples

Example 1

{
  "nums": [3, 9, 7, 3]
}

Output: diff 2

Example 2

{
  "nums": [1, 1, 1, 5]
}

Output: diff 4

Rebuild it in the studio

Open every published interview problem, solution, scene, and memory room free, with no account.

More Dynamic Programming problems