Skip to content
LC-3487 Easy LeetCode

3487. Maximum Unique Subarray Sum After Deletion

Read the full problem statement on LeetCode.
Difficulty: easy Acceptance: 27% Topics: Array, Hash Table, Greedy
View full problem on LeetCode
Reference solution (spoiler · python)
# Time:  O(n)
# Space: O(n)

# hash table
class Solution(object):
    def maxSum(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        mx = max(nums)
        return mx if mx < 0 else sum(x for x in set(nums) if x >= 0)

Solution from kamyu104/LeetCode-Solutions · MIT