Leetcode 2926. Maximum Balanced Subsequence Sum
Choose a subsequence maximizing sum under the constraint nums[i_j] - nums[i_{j-1}] >= i_j - i_{j-1], which is equivalent to requiring the transformed values v[i] = nums[i] - i be nondecreasing along the subsequence. The problem reduces to finding the maximum-sum nondecreasing subsequence of v (n up to 1e5), solvable by DP with range-maximum queries (e.g., Fenwick/segment tree) in O(n log n).
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
0
Hello Interview Premium
Your account is free and you can post anonymously if you choose.