find the number of non-empty subsets S such that min(S) + max(S) <= K : // For a given vector of integers and integer K, find the number of non-empty subsets S such that min(S) + max(S) <= K 
// For example, for K = 8 and vector [2, 4, 5, 7], the solution is 5 ([2], [4], [2, 4], [2, 4, 5], [2, 5]) 
The time complexity should be O(n2). Approach and code was asked