Remove One Element to Minimize Pairwise Absolute Differences

Given an array arr of positive integers with odd length. You must remove exactly one element, then pair all remaining elements arbitrarily.

The cost of a pairing is the sum of absolute differen...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: