Reported August 2024
IBMhash table

Get Maximum Occurances

Reported by candidates from IBM's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live IBM OA. Under 2s to a working solution.
Founder's read

IBM hit you with a frequency problem in August 2024, and it's simpler than it sounds. You're looking at an array and need to find the element that shows up most often, then return how many times it appears. This is a hash-table play, pure counting. The trick is knowing when to stop counting. StealthCoder reads the problem and spots the pattern instantly if you freeze mid-approach, but the real move is getting the hash-map logic tight before the OA starts.

Pattern and pitfall

Build a hash map to track element frequencies as you iterate through the array. The algorithm is O(n) time and O(n) space, which is optimal. The gotcha candidates miss: off-by-one errors when comparing max counts, or forgetting to initialize the map entry before incrementing. Some candidates overthink and sort, which burns time unnecessarily. Walk the array once, count each element, track the running maximum, return the count of the most frequent element. If you blank on the hash-map approach during the live OA, StealthCoder will show you the exact skeleton code and let you fill in the logic while the proctor sees nothing.

StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.

If this hits your live OA

You can drill Get Maximum Occurances 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. If you're reading this with an OA window open, you're who this was built for.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as majority element. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass IBM's OA.

IBM reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Get Maximum Occurances FAQ

Do I have to return the element or just the count?+

The problem title says 'occurrences,' so you're returning the integer count, not the element itself. Read the expected output format in your OA carefully, but frequency problems almost always ask for the number. One quick scan of the examples and you'll know for sure.

What if there's a tie for most frequent?+

The problem doesn't specify ties, so assume there's always a unique maximum or the OA expects any one of them. If ties exist and they want all of them, the output format will make that clear. Hash-map approach handles this gracefully either way.

Can I use Python's Counter or Java's HashMap?+

Yes. Standard library tools are fair game in every OA. Counter in Python is idiomatic and faster than rolling your own. HashMap or HashTable in Java does the same job. Use what you're comfortable with.

How hard is this really compared to other IBM OAs?+

This is warm-up hard. It's testing if you know hash-maps and can code without syntax errors. Not a trick, not a DP monster. Get it right and move on. IBM uses this to filter for baseline competence.

What if the array is empty or has one element?+

Edge cases matter. Empty array might return 0 or throw an error depending on spec. Single element returns 1. Your OA examples will show you the bounds. Always check before submitting.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with IBM.

OA at IBM?
Invisible during screen share
Get it