Skip to content

Practice Minimum Difference in Sums After Removal of Elements

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#2163
LeetCode Problem

Minimum Difference in Sums After Removal of Elements

Problem Statement

nums has 3n entries. Remove exactly n entries while preserving the relative order of those kept. Split the remaining 2n entries into their first n and final n, and return the smallest possible first-part sum minus second-part sum. This is a signed difference, not an absolute difference.

Source: Minimum Difference in Sums After Removal of Elements on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [3,1,2]
Output
-1

# Example 2

Input
nums = [7,9,5,8,1,3]
Output
1

Constraints

nums.length == 3 * n
1 <= n <= 10^5
1 <= nums[i] <= 10^5

Related LeetCode Problems

Practice more problems similar to Minimum Difference in Sums After Removal of Elements.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.