Most Simple solution using simple combination technique
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 p =1e5 + 9; 
   const int q = 71 ;
class Solution {
public:

     int ncr[p][q]  ; 

    int minMaxSums(vector<int>& nums, int k) {
     
      {
          ncr[0][0] = 1; 
          int n = nums.size() ; 
          for(int i = 1 ; i <= n ; i++) {
             for(int j = 0 ; j <= min(i , k) ; j++)  {
                if(j == 0 || j == i) ncr[i][j] = 1 ; 
                else ncr[i][j] = (ncr[i-1][j] + ncr[i-1][j-1]) % mod ; 
             }
          }
      }



        int n = nums.size() ; 
        sort(nums.begin() , nums.end()) ; 
        int ans = 0; 
        for(int i =0 ; i < n ; i++) {
              for(int r  = 0 ; r < k && r <n; r++) {
                ans = (ans +  (1LL*nums[i] * ncr[n-i-1][r] % mod) % mod ) % mod ; 
              }
        }
         reverse(nums.begin() , nums.end()) ; 
         for(int i = 0 ; i < n ; i++) {
             for(int r = 0 ; r < k && r < n ; r++) {
                ans = (ans +  (1LL*nums[i] * ncr[n-i-1][r] % mod) % mod ) % mod ; 

             }
         }

         return ans ; 
    }
};
```
['Combinatorics', 'C++']