Skip to content
LC-1748 Easy LeetCode

1748. Sum of Unique Elements

Read the full problem statement on LeetCode.
Difficulty: easy Acceptance: 79% Topics: Array, Hash Table, Counting
View full problem on LeetCode

Reading material

Reference solution (spoiler · python)
# Time:  O(n)
# Space: O(n)

import collections


class Solution(object):
    def sumOfUnique(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        return sum(x for x, c in collections.Counter(nums).iteritems() if c == 1)

Solution from kamyu104/LeetCode-Solutions · MIT