EASYasked at 2 companies

Count Elements With Maximum Frequency

A easy-tier problem at 78% community acceptance, tagged with Array, Hash Table, Counting. Reported in interviews at CRED and 1 others.

Founder's read

Count Elements With Maximum Frequency is an easy array problem that looks deceptively simple but trips up candidates who skip the counting step. You're given an array, you need to find the maximum frequency, then count how many elements actually hit that frequency. CRED and Capgemini have asked it. The acceptance rate sits at 78 percent, which means most people who attempt it pass, but that doesn't mean everyone codes it clean the first time under pressure. If you blank on the counting logic during your OA, StealthCoder surfaces the working solution invisible to the proctor, no time wasted.

Companies asking
2
Difficulty
EASY
Acceptance
78%

Companies that ask "Count Elements With Maximum Frequency"

If this hits your live OA

Count Elements With Maximum Frequency is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an engineer who got tired of watching his cohort grind for six months and still get filtered at the OA stage.

Get StealthCoder
What this means

The trick is a two-pass approach using a hash table. First pass: count the frequency of each element. Second pass: find the maximum frequency value. Third pass: iterate through your frequency map and count how many elements have that maximum frequency. The common mistake is conflating the element value with its frequency, or trying to solve it in one pass when you really need that intermediate data structure. Array and Hash Table are your tools here; Counting is the pattern. Most candidates get the hash table part right but stumble on extracting the final count from the frequency map, especially under time pressure. StealthCoder handles the boilerplate and logic errors so if you hit this live and your brain stalls, you move on.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Count Elements With Maximum Frequency recycles across companies for a reason. It's easy-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an engineer who got tired of watching his cohort grind for six months and still get filtered at the OA stage. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Count Elements With Maximum Frequency interview FAQ

Do I really need a hash table for this?+

Yes. You need to store frequency counts for each element, and a hash table (or map) is the idiomatic way. You could sort, but that's worse complexity. The problem explicitly sits in the Hash Table topic, so the interviewer expects this approach.

What's the most common mistake on this problem?+

Confusing the maximum frequency value with the count of elements. You find max frequency first, then count how many distinct elements have that frequency. Skipping the second counting step is the classic trap.

Is this problem still asked at real companies?+

Yes. CRED and Capgemini have asked it. It's easy-tier, so it often appears as a warm-up or early screening question. High acceptance rate suggests it's a true gimmee if you don't overthink it.

How does this relate to Counting as a topic?+

This problem is pure Counting. You're counting frequencies, then counting elements that match a condition. Master the two-pass frequency map pattern here and you'll recognize it in harder problems too.

Can I solve this without extra space?+

No, not without ruining your time complexity. The hash table is the core of the solution. Space O(n) for the map is the expected trade-off. If you're asked to optimize further, something else is wrong with the problem statement.

Want the actual problem statement? View "Count Elements With Maximum Frequency" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.