Find the Odd-Occurrence Value
Updated
Problem statement
You are given a nonempty integer array values. Exactly one distinct value occurs an odd number of times, and every other value occurs an even number of times.
Return the value whose occurrence count is odd. Array order does not affect the result.
Function
findOdd(values: int[]) → intExamples
Example 1
values = [5,5,6,4,6]return = 4The values 5 and 6 each occur twice. The value 4 occurs once, so return 4.
Example 2
values = [9,1,9,9,1]return = 9The value 9 occurs three times, and 1 occurs twice. Three is odd, so the answer is 9.
Constraints
1 <= values.length <= 100000.-1000000000 <= values[i] <= 1000000000.- Exactly one distinct value occurs an odd number of times; every other distinct value occurs an even number of times.
More Expedia Onsite Interview questions
- Scramble StringONSITE INTERVIEW · Seen Sep 2026
- Smallest Sufficient TeamONSITE INTERVIEW · Seen Sep 2026
- Check Anagram Pairs Index by IndexONSITE INTERVIEW · Seen Oct 2025
- Fresh Oranges Left After Rotting StopsONSITE INTERVIEW · Seen Oct 2025
- Longest Increasing SubsequenceONSITE INTERVIEW · Seen Oct 2025
- Lowest Common Ancestor with Repeated and Missing ValuesONSITE INTERVIEW · Seen Oct 2025
- Shortest Substring with Exactly K OnesONSITE INTERVIEW · Seen Oct 2025
- Middle Element of a Linked ListONSITE INTERVIEW · Seen Nov 2024
- Minimum in a Rotated Sorted ArrayONSITE INTERVIEW · Seen Sep 2024
- Mirror Image Binary TreesONSITE INTERVIEW · Seen Sep 2024
Similar questions at other companies
- Find the Missing Number from 1 to nHyperVerge · ONSITE INTERVIEW
- Missing and Repeated NumberCommvault · ONSITE INTERVIEWCommvault interview questions
- Check Endianness Of A Byte ArrayNVIDIA · ONSITE INTERVIEWNVIDIA interview questions
- Count Set Bits in an Integer ArrayAkuna Capital · ONSITE INTERVIEWAkuna Capital interview questions
- Packed Bit Array: Set and Reset BitsNutanix · ONSITE INTERVIEWNutanix interview questions
- Find the Two Unique NumbersZomato / Eternal · ONSITE INTERVIEWZomato / Eternal interview questions
- Bayesian Scenario ClassifierAmazon · ONSITE INTERVIEW
- Maximum Unique-Character Word SubsetMeta · ONSITE INTERVIEWMeta interview questions
- Hybrid Run-Length and Bit-Packing EncoderDatabricks · ONSITE INTERVIEWDatabricks interview questions
- Largest Combination With Bitwise AND Greater Than ZeroMicrosoft · ONSITE INTERVIEWMicrosoft interview questions