You are given an Integer list nums
consisting of n
elements.
An element is unique if it appears exactly once in the list. Return the sum of all the unique elements in nums
. If no elements are unique, return 0.
Example 1:
Input: nums = [4, 3, 12, 3]
Output: 16
Explanation: 3 is not unique. 4 and 12 are unique. 4 + 12 = 16
Example 2:
Input: nums = [32]
Output: 32
Explanation: 32 is the only number
Example 3:
Input: nums = [1, 2, 3]
Output: 6
Explanation: Every number is unique. 1 + 2 + 3 = 6.
Constraints
n == nums.size()
1 <= n < 10