Simple C++ Solution.
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
const  int mod = 1e9+7;
const int N = 1e5+1;
const int R = 1e2+1;
class Solution {
int NCR[N][R];    
public:
    int minMaxSums(vector<int>& nums, int k) {
        int ans =0;  
        int size = nums.size();
        for(int i=0;i<=size;i++) NCR[i][0]= 1;
        for(int j=1;j<=k;j++)  NCR[0][j]=0;

        for(int i=1;i<=size;i++){
            for(int j=1;j<=k;j++){
                NCR[i][j] = ((NCR[i-1][j-1])%mod+(NCR[i-1][j])%mod)%mod;
            }
        }
        sort(nums.begin(), nums.end());
        //finding contribution of each element as min and max
        for(int i=0;i<size;i++){
            for(int j=1;j<=k;j++){
                long long temp =  ((long long)(NCR[size - 1 - i][j - 1]) % mod * nums[i] % mod) % mod;
                ans =  (ans + temp)%mod;
               


            }
        }
        reverse(nums.begin(),nums.end());
        for(int i=0;i<size;i++){
            for(int j=1;j<=k;j++){
                long long temp =  ((long long)(NCR[size - 1 - i][j - 1]) % mod * nums[i] % mod) % mod;
                ans =  (ans + temp)%mod;
            }
        }
        return ans;
        
    }
};
```
['C++']