Find the Element With Odd Frequency
Updated
Problem statement
Given a nonempty integer array values, exactly one distinct value occurs an odd number of times. Every other distinct value occurs an even number of times.
Return the value whose frequency is odd.
Function
findOddFrequencyElement(values: int[]) → intExamples
Example 1
values = [2,3,2,3,3]return = 3Value 2 appears twice, while 3 appears three times.
Example 2
values = [7]return = 7The only value appears once, which is odd.
Example 3
values = [10,20,10,20,10,20,10]return = 20Value 10 appears four times and 20 appears three times.
Constraints
1 <= values.length <= 200000-10^9 <= values[i] <= 10^9- Exactly one distinct value has odd frequency; every other distinct value has even frequency.
More Zscaler interview questions
- Rate Limiter with Hourly and Daily Effort QuotasPHONE SCREEN · Seen Jul 2026
- Merging PalindromesPHONE SCREEN · Seen Sep 2024
- Merge IntervalsPHONE SCREEN · Seen Jun 2024
- Sum of Divisors of the Array GCDPHONE SCREEN · Seen Jun 2024
- Asteroid CollisionONSITE INTERVIEW · Seen Sep 2024
- Check Whether a Byte Is NonzeroONSITE INTERVIEW · Seen Sep 2024
- Count Vowel PermutationsONSITE INTERVIEW · Seen Sep 2024
- Longest Common Subsequence LengthONSITE INTERVIEW · Seen Jun 2024
- Run-Length EncodingONSITE INTERVIEW · Seen Jun 2024
- How Many Sentences? 🌿OA · Seen Mar 2024
Similar questions at other companies
- Find the Unique Element Among PairsChubb · PHONE SCREENChubb interview questions
- The One Repeated NumberAdobe · PHONE SCREENAdobe interview questions
- SubsetsTemu · PHONE SCREENTemu interview questions
- Minimum Cost for a Target WeightPace Stock Broking Services · PHONE SCREEN
- Minimum Racks for Server ResourcesGoogle · PHONE SCREENGoogle interview questions
- Out-of-Order TLV File ReassemblyApplied Intuition · PHONE SCREENApplied Intuition interview questions
- Ordered IP FirewallDatabricks · PHONE SCREENDatabricks interview questions
- Count String Pairs With Disjoint CharactersNetflix · PHONE SCREENNetflix interview questions
- SubsetsBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
- Reconstruct an Array from Prefix XORNVIDIA · OANVIDIA interview questions