FastPrepFind the Unique Element Among Pairs
Problems/Find the Unique Element Among Pairs

Find the Unique Element Among Pairs

Chubb logoChubb● EasyNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A report asks for the one array element that is unique when every other element appears twice. We chose the rest. The input is not sorted, and every other value appears exactly twice. We also chose the function types, the examples, and the limits.

You are given a nonempty integer array nums. Exactly one value appears once and every other value appears exactly twice.

Return the value that appears once. The input is not necessarily sorted.

Function

singleNumber(nums: int[]) → int

Examples

Example 1

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

The values 1 and 2 form pairs, leaving 4.

Example 2

nums = [-7,3,3]return = -7

The two 3 values cancel as a pair.

Constraints

  • 1 <= nums.length <= 200001.
  • nums.length is odd.
  • -1000000000 <= nums[i] <= 1000000000.
  • Exactly one value appears once; every other value appears twice.

More Chubb interview questions

  • Reverse a Singly Linked ListPHONE SCREEN · Seen Oct 2026
  • Second-Highest Distinct SalaryPHONE SCREEN · Seen Oct 2026
  • Count Pairs with K Divisible Values in the IntervalOA · Seen Oct 2026
  • Index of the Maximum After Left RotationsOA · Seen Oct 2026
  • Maximize Revenue from Decreasing InventoryOA · Seen Oct 2026
  • Minimize the Maximum Array ElementOA · Seen Oct 2026
  • Minimum Distinct Prefix CostOA · Seen Oct 2026
  • Flat JSON Value DifferencesOA · Seen Sep 2026
  • Maximum Student-Teacher DistanceOA · Seen Sep 2026
  • Minimum Cost to Reach a Target WeightOA · Seen Sep 2026

Similar questions at other companies

  • The One Repeated NumberAdobe · PHONE SCREENAdobe interview questions
  • Wildcard Address-Book QueriesGoogle · PHONE SCREENGoogle interview questions
  • Palindrome-Rearrangeable PairsExpedia · OAExpedia interview questions
  • Count Subarrays with a Perfect-Square ProductMicrosoft · OAMicrosoft interview questions
  • Optimize Discount Selection Under a Point BudgetPalantir · OAPalantir interview questions
  • Bitwise XOR SubsequencesJP Morgan Chase · OAJP Morgan Chase interview questions
  • Count Valid Bitwise PairsStripe · OAStripe interview questions
  • Bitwise XOR SubsequencesGoldman Sachs · OAGoldman Sachs interview questions
  • Count Subarrays With Given XORInMobi · OAInMobi interview questions
  • Sparse Vector Dot Product from TuplesMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
All Chubb interview questionsSee Chubb hiring insights
Saved
class Solution {
    public int singleNumber(int[] nums) {
        // Write your solution here.
    }

}
Checking account…