Sum of Unique Elements

Problem Id: 1748 Difficulty: Easy Tag: Array Tag: Hash Table


Since the length of the given is only less than 100. The simplest way to solve it is using brute force.


class Solution:
    def sumOfUnique(self, nums: List[int]) -> int:
        s = 0
        for num in nums:
            if nums.count(num) == 1:
                s += num
        return s