Single Number with Triplicates
Updated
Problem statement
Given a nonempty integer array nums, every value appears exactly three times except for one value that appears once. Return that single value.
Your solution must run in O(n) time and use O(1) auxiliary space.
Function
singleNumberTriplicates(nums: int[]) → intExamples
Example 1
nums = [2,2,3,2]return = 3Only 3 occurs once.
Example 2
nums = [0,1,0,1,0,1,99]return = 99Zero and one occur three times; 99 occurs once.
Constraints
1 <= nums.length <= 300001- Every value fits in a signed 32-bit integer.
- Exactly one value appears once; every other distinct value appears three times.
More Goldman Sachs Onsite Interview questions
- Best Average Student ScorePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Knight Probability in ChessboardONSITE INTERVIEW · Seen Nov 2026
- Meeting RoomsPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Minimum Meeting Rooms Without a Sweep LineONSITE INTERVIEW · Seen Oct 2026
- First Non-Repeating CharacterPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Root of the Largest TreePHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Dungeon HealthONSITE INTERVIEW · Seen Sep 2026
- Insert, Delete, And Get Random In Constant TimeONSITE INTERVIEW · Seen Sep 2026
- Least Recently Used CacheONSITE INTERVIEW · Seen Sep 2026
- Staircase Search In A Sorted MatrixONSITE INTERVIEW · Seen Sep 2026
Similar questions at other companies
- Find the Two Unique NumbersZomato / Eternal · ONSITE INTERVIEWZomato / Eternal interview questions
- Smallest Sufficient TeamExpedia · ONSITE INTERVIEWExpedia interview questions
- Bayesian Scenario ClassifierAmazon · ONSITE INTERVIEW
- Maximum Unique-Character Word SubsetMeta · ONSITE INTERVIEWMeta interview questions
- Largest Combination With Bitwise AND Greater Than ZeroMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Game of Life: In-Place Next GenerationGoogle · ONSITE INTERVIEWGoogle interview questions
- 2048 Simulation and Board CodecCitadel · ONSITE INTERVIEWCitadel interview questions
- SubsetsBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
- BitFont - Maximum Non-Overlapping KerningStripe · ONSITE INTERVIEWStripe interview questions
- Find the Value Occurring Exactly OnceMorgan Stanley · ONSITE INTERVIEWMorgan Stanley interview questions