My Solution
```
/**
 * Time Complexity: O(n * (log(n) + k))
 * Space Complexity: O(n * k)
 * where `n` is the length of the vector `nums`
 */
class Solution {
 private:
  static constexpr int mod = 1000000007;

 public:
  int minMaxSums(vector<int> &nums, const int k) {
    const int n = static_cast<int>(nums.size());
    int comb[n][k];
    memset(comb, 0, sizeof(comb));
    comb[0][0] = 1;
    for (int i = 1; i < n; ++i) {
      comb[i][0] = 1;
      for (int j = 1; j < k; ++j) {
        comb[i][j] = plus(comb[i - 1][j], comb[i - 1][j - 1]);
      }
    }

    for (int i = 1; i < n; ++i) {
      for (int j = 1; j < min(i + 1, k); ++j) {
        comb[i][j] = plus(comb[i][j], comb[i][j - 1]);
      }
    }

    sort(nums.begin(), nums.end());
    int ret = 0;
    for (int i = 0; i < n; ++i) {
      ret = plus(
        plus(
          ret,
          mult(nums[i], comb[n - i - 1][min(k - 1, n - i - 1)])
        ),
        mult(nums[i], comb[i][min(k - 1, i)])
      );
    }
    return ret;
  }

 private:
  int mult(const int a, const int b) {
    return static_cast<int>((static_cast<long long>(a) * b) % mod);
  }

  int plus(const int a, const int b) {
    return (a + b) % mod;
  }
};
```
['C++']