Find the Value of the Partition
Sort the numbers; the cheapest split always falls between two neighbouring values, so the answer is the smallest gap.
Sort the numbers; the cheapest split always falls between two neighbouring values, so the answer is the smallest gap.