Tap here to switch tabs
Problem
Submissions

Problem: Delete and Earn

Delete and Earn gives you an integer array. Repeatedly choose an element to earn its value, while deleting all elements whose values are one less or one greater. Return the maximum total points.

Statement

Given an integer array nums, maximize the total points you can earn by repeatedly performing the following operation:

Choose an element nums[i] and delete it to earn nums[i] points. After deleting it, every element with value nums[i] - 1 or nums[i] + 1 must also be deleted, but these deleted elements earn no points.

Return the maximum number of points you can earn.

Constraints:

  • 1≤1 \leq nums.length ≤2×104\leq 2 \times 10^4

  • 1≤1 \leq nums[i] ≤104\leq 10^4

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Delete and Earn

Delete and Earn gives you an integer array. Repeatedly choose an element to earn its value, while deleting all elements whose values are one less or one greater. Return the maximum total points.

Statement

Given an integer array nums, maximize the total points you can earn by repeatedly performing the following operation:

Choose an element nums[i] and delete it to earn nums[i] points. After deleting it, every element with value nums[i] - 1 or nums[i] + 1 must also be deleted, but these deleted elements earn no points.

Return the maximum number of points you can earn.

Constraints:

  • 1≤1 \leq nums.length ≤2×104\leq 2 \times 10^4

  • 1≤1 \leq nums[i] ≤104\leq 10^4