0740. Delete and Earn
https://leetcode.com/problems/delete-and-earn
Description
You are given an integer array nums
. You want to maximize the number of points you get by performing the following operation any number of times:
Pick any
nums[i]
and delete it to earnnums[i]
points. Afterwards, you must delete every element equal tonums[i] - 1
and every element equal tonums[i] + 1
.
Return the maximum number of points you can earn by applying the above operation some number of times.
Example 1:
Example 2:
Constraints:
1 <= nums.length <= 2 * 104
1 <= nums[i] <= 104
ac
Last updated