Sum-subset with a fixed subset size
For k=4, space complexity O(n), time complexity O(n2 * log(n)) Sort the array. Starting from 2 smallest and 2 largest elements, calculate all lesser sums of 2 elements (a[i] + a[j]) in the non-decreasing order and all greater sums of 2 elements (a[k] + a[l]) in the non-increasing order. Increase lesser sum if total sum … Read more