Tap here to switch tabs
Problem
Submissions

Problem: Minimum Difference in Sums After Removal of Elements

med
30 min
Try to solve the Minimum Difference in Sums After Removal of Elements problem.

Statement

You are given an integer array nums consisting of 3imesn3 imes n elements.

You must remove exactly nn elements from nums, leaving 2imesn2 imes n elements. The remaining elements are partitioned into two equal parts:

  • The first part contains the first nn elements.

  • The second part contains the remaining nn elements.

The difference between the two parts is defined as the sum of the elements in the first part minus the sum of the elements in the second part.

Return the minimum possible difference after removing nn elements.

Constraints:

  • nums.length =3imesn= 3 imes n

  • 1≤n≤1051 \leq n \leq 10^5

  • 1≤1 \leq nums[i] ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Difference in Sums After Removal of Elements

med
30 min
Try to solve the Minimum Difference in Sums After Removal of Elements problem.

Statement

You are given an integer array nums consisting of 3imesn3 imes n elements.

You must remove exactly nn elements from nums, leaving 2imesn2 imes n elements. The remaining elements are partitioned into two equal parts:

  • The first part contains the first nn elements.

  • The second part contains the remaining nn elements.

The difference between the two parts is defined as the sum of the elements in the first part minus the sum of the elements in the second part.

Return the minimum possible difference after removing nn elements.

Constraints:

  • nums.length =3imesn= 3 imes n

  • 1≤n≤1051 \leq n \leq 10^5

  • 1≤1 \leq nums[i] ≤105\leq 10^5