Find Max Frequency
Reported by candidates from Google's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Google's November OA is asking you to find max frequency, and it's a hash-table problem dressed up as a frequency counter. You're looking at a pattern that shows up constantly in real interviews: build a map of counts, then extract the maximum. The trap is thinking you need to sort or optimize prematurely. StealthCoder will catch you if you freeze on the implementation during the live OA.
Pattern and pitfall
The core move is straightforward: iterate through your input (array, string, or stream), count occurrences in a hash map, then traverse the map to find the key with the highest count. Common pitfall: candidates waste time on sorting the entire map when they just need one pass through it to track the running max. Edge cases matter: handle empty input, ties in frequency, and single-element input. The algorithm runs in O(n) time and O(k) space where k is the number of unique elements. If the problem asks for the element itself, return it directly. If it asks for the frequency value, return the count. StealthCoder surfaces the exact pattern in seconds, so you don't blank on syntax or the final extraction logic.
If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.
You can drill Find Max Frequency cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it.
Get StealthCoderRelated leaked OAs
This OA pattern shows up on LeetCode as majority element. If you have time before the OA, drill that.
You've seen the question.
Make sure you actually pass Google's OA.
Google reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Find Max Frequency FAQ
Is this a sorting problem in disguise?+
No. You don't need to sort the map. Build a frequency hash map in one pass, then iterate through it once more to track the maximum count. O(n) beats any sort-based approach. The trick is knowing when you can skip the sort.
What if multiple elements have the same max frequency?+
The problem will specify: return one element, all elements, or just the count. Read the exact requirement. If it says 'return the element', return any one. If it says 'return all', collect them into a list. Check the problem text carefully.
Does the input order matter?+
Not for finding max frequency. You're just counting. Hash maps don't preserve order in many languages, but that's fine because you're extracting a single max value, not a sorted output.
How do I prep for this in 48 hours?+
Code the hash-map counting pattern twice in your target language. Practice extracting the max in one pass. Handle empty input and tie-breaking. That's it. The problem is pattern recognition, not complexity.
Will Google ask for optimizations after the base solution?+
Possibly. Be ready to discuss space-time tradeoffs, stream processing if the input is huge, or early termination if you're looking for 'top k' frequencies. But nail the hash-table solution first.