#3487
Maximum Unique Subarray Sum After Deletion
easy · 40.5% accepted · 473 likes · top 20%
array · hash table · greedy
Description
You are given an integer array nums.
You are allowed to delete any number of elements from nums without making it empty. After performing the deletions, select a subarray of nums such that:
- All elements in the subarray are unique.
- The sum of the elements in the subarray is maximized.
Return the maximum sum of such a subarray.
Solution