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

Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.

More Dynamic Programming problems