Count Values Appearing Exactly Once
Problem statement
Given an integer array nums, return how many distinct values occur exactly once in the array.
A value contributes one to the answer only when its total frequency is one. Values that occur two or more times do not contribute.
Function
countAppearingOnce(nums: int[]) → intExamples
Example 1
nums = [4,2,1,4,4,1,3]return = 2Only 2 and 3 appear exactly once.
Example 2
nums = [7,7,7]return = 0The only value occurs three times.
Example 3
nums = [-1,0,5]return = 3Every value occurs once.
Constraints
1 <= nums.length <= 10^5.-10^9 <= nums[i] <= 10^9.