Divide a sorted array in K parts with sum of difference of max and min minimized in each part
Given an ascending sorted array arr[] of size N and an integer K, the task is to partition the given array into K non-empty subarrays such that the sum of differences of the maximum and the minimum of each subarray is minimized. Examples: Input: arr[] = {4, 8, 15, 16, 23, 42}, K = 3 Output: 12 Expla