Tap here to switch tabs
Problem
Submissions

Problem: Maximum and Minimum Sums of at Most Size K Subsequences

Try to solve the Maximum and Minimum Sums of at Most Size K Subsequences problem.

Statement

You are given an integer array nums and a positive integer k.

Return the sum of the minimum and maximum values of all non empty subsequences of nums with a size of at most k. Since the answer may be very large, return it modulo 109+710^9 + 7.

Note: A subsequence is a sequence that can be derived from an array by deleting zero or more elements without changing the order of the remaining elements.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 0≤0 \leq nums[i] ≤109\leq 10^9

  • 1≤1 \leq k ≤min⁡(70,\leq \min(70, nums.length))

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum and Minimum Sums of at Most Size K Subsequences

Try to solve the Maximum and Minimum Sums of at Most Size K Subsequences problem.

Statement

You are given an integer array nums and a positive integer k.

Return the sum of the minimum and maximum values of all non empty subsequences of nums with a size of at most k. Since the answer may be very large, return it modulo 109+710^9 + 7.

Note: A subsequence is a sequence that can be derived from an array by deleting zero or more elements without changing the order of the remaining elements.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 0≤0 \leq nums[i] ≤109\leq 10^9

  • 1≤1 \leq k ≤min⁡(70,\leq \min(70, nums.length))