FastPrepCount Values Appearing Exactly Once
Problems/Count Values Appearing Exactly Once

Count Values Appearing Exactly Once

Agoda logoAgoda● EasyFULLTIMEPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: The interview report directly asks how many integers occur exactly once and supplies the representative example. The judged interface adds only ordinary bounds. The practice contract matches the report at about 99%.

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[]) → int

Examples

Example 1

nums = [4,2,1,4,4,1,3]return = 2

Only 2 and 3 appear exactly once.

Example 2

nums = [7,7,7]return = 0

The only value occurs three times.

Example 3

nums = [-1,0,5]return = 3

Every value occurs once.

Constraints

  • 1 <= nums.length <= 10^5.
  • -10^9 <= nums[i] <= 10^9.

More Agoda problems

  • Sort Ones, Twos, and Threes In PlacePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Can Place FlowersPHONE SCREEN · Seen Nov 2026
  • Reverse Words in a StringPHONE SCREEN · Seen Nov 2026
All Agoda interview questionsSee Agoda hiring insights
Saved
class Solution {
    public int countAppearingOnce(int[] nums) {
        // Write your solution here.
    }
}
Checking account…