Search
⌘K

Leetcode 2163. Minimum Difference in Sums After Removal of Elements

Given an array of length 3n, remove exactly n elements so the remaining 2n elements (split into the first n and last n) have the smallest possible difference between their sums. The challenge is to choose which elements to remove, typically solved by scanning possible middle split points and using heap-based prefix/suffix greedy computations to precompute the best n-element sums on each side and minimize their difference.

Asked at:

Amazon

Amazon


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Early January, 2025

Amazon

Amazon

Mid-level

Maximizing Weighted Array Difference: Remove n/3 items from an array to maximize the difference between the sum of the first half and the sum of the second half of the remaining elements.

Comments

Your account is free and you can post anonymously if you choose.