2926. Maximum Balanced Subsequence Sum
You are given a 0-indexed integer array
nums
.A subsequence of
nums
having lengthk
and consisting of indicesi0 < i1 < ... < ik-1
is balanced if the following holds:
nums[ij] - nums[ij-1] >= ij - ij-1
, for everyj
in the range[1, k - 1]
.A subsequence of
nums
having length1
is considered balanced.Return an integer denoting the maximum possible sum of elements in a balanced subsequence of
nums
.A subsequence of an array is a new non-empty array that is formed from the original array by deleting some (possibly none) of the elements without disturbing the relative positions of the remaining elements.
c++
1 |
|