Sum of Unique Elements

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


Intuition

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

Solution


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