Count Distinct Selections
Updated
Problem statement
Each integer in selections identifies one selected item. Return how many different item IDs occur. Repeated selections count once. An empty sequence returns zero.
Function
countSelections(selections: int[]) → intExamples
Example 1
selections = [4,2,4,7,2]return = 3The IDs are 2, 4, and 7.
Example 2
selections = []return = 0No item was selected.
Constraints
- For this exercise, assume at most 200000 selections and IDs between -10^9 and 10^9.
More Intuit Online Assessment questions
- Employee Promotion OpportunitiesOA · Seen Oct 2026
- Next Pascal Row CoefficientOA · Seen Oct 2026
- Parse Router LogsOA · Seen Oct 2026
- Longest Repeated Letter Block with Adjacent SwapsOA · Seen Oct 2026
- Maximum Square-Free DivisorOA · Seen Oct 2026
- Two Tribes from Taller-Person CountsOA · Seen Oct 2026
- Shortest Path from an Encoded GraphOA · Seen Sep 2026
- Oldest and Youngest EmployeesOA · Seen Sep 2026
- Pressure-Isolation Shutdown OrderOA · Seen Sep 2026
- Submask Sum QueriesOA · Seen Sep 2026
Similar questions at other companies
- Count User Mentions in Chat MessagesRamp · OARamp interview questions
- Count Valid Square PairsAuxoAI · OA
- Two SumAmazon · OA · PHONE SCREEN
- Find Words That Can Be Formed by CharactersTabaPay · OA
- Basic Item DiscountsPalantir · OAPalantir interview questions
- Word Frequency Counts in Alphabetical OrderAbridge · OAAbridge interview questions
- Customer Signer ScreeningState Farm · OA
- Minimum Magic Stones After MergesElevenLabs · OAElevenLabs interview questions
- K Most Recent Unique Request IDsMicrosoft · OAMicrosoft interview questions
- Distinct Products After Removing One ElementHSBC · OAHSBC interview questions