3428. Maximum and Minimum Sums of at Most Size K Subsequences
You are given an integer array
nums
and a positive integerk
. Return the sum of the maximum and minimum elements of all subsequences ofnums
with at mostk
elements.Since the answer may be very large, return it modulo
109 + 7
.
c++
1 | long long mod = 1e9 + 7; |