✅ Easiest DP | No Combination | Recursion | Sorting
DP(n, k) returns the total number of subsequences if we have n elements and we can take at most k elements in a subsequence.Contribution of nums[i] will be sum
`DP(n, k)` returns the `total number of subsequences` if we have `n` elements and we can take at most `k` elements in a subsequence.

Contribution of `nums[i]` will be sum of this two. 
- number of times it is minimum
- number of times it is maximum

Runtime 209 ms |  Beats 91.56%

# Code
```cpp []
#define ll long long
#define v vector
#define v1 v<ll>
#define v2 v<v1>
#define mod 1000000007

v2 dp(100001, v1(71, -1));

class Solution {
public:
    ll DP(ll n, ll k) {
        if (n == 0 || k == 0) return 1;
        if (dp[n][k] != -1) return dp[n][k];
        return dp[n][k] = (DP(n - 1, k) + DP(n - 1, k - 1)) % mod;
    }

    int minMaxSums(vector<int>& nums, int k) {
        ll n = nums.size(), ans = 0;
        sort(nums.begin(), nums.end());
        for (ll i = 0; i < n; i++) {
            ll contribution_as_mx = (nums[i] * DP(i, k - 1)) % mod;
            ll contribution_as_mn = (nums[i] * DP(n - i - 1, k - 1)) % mod;
            ans = (ans + contribution_as_mx + contribution_as_mn) % mod;
        }
        return ans;
    }
};
```
['C++']