HARDasked at 1 company

Maximum Equal Frequency

A hard-tier problem at 37% community acceptance, tagged with Array, Hash Table. Reported in interviews at American Express and 0 others.

Founder's read

Maximum Equal Frequency hits the hard tier with a 37% acceptance rate, and American Express has reportedly asked it. The problem looks deceptively simple on the surface but punishes candidates who don't recognize the trick: you're looking for the longest prefix where every element appears with equal frequency, or where removing one element achieves that state. Most people brute-force frequency counts and get TLE or miss the key insight that valid states follow a predictable pattern. If this lands in your live assessment and you blank on the pattern recognition, StealthCoder surfaces a working solution in seconds, invisible to the proctor.

Companies asking
1
Difficulty
HARD
Acceptance
37%

Companies that ask "Maximum Equal Frequency"

If this hits your live OA

Maximum Equal 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. Made by a working FAANG engineer who treats the OA the way companies treat hiring: as a game with rules you should know.

Get StealthCoder
What this means

The trap is treating this as a straightforward frequency-count problem. You'll quickly write code that works on examples but fails on edge cases or times out. The real solution recognizes that only a handful of frequency states are valid: all elements appear f times, all but one appear f times with one appearing f+1 times, one element appears once and the rest appear f times, or the entire prefix is a single unique element. Using a hash table to track frequency counts and another to count how many elements share each frequency, you can check validity in O(1) per index instead of re-scanning. The pattern-based approach cuts the problem from O(n^2) to O(n) linear time. This is the kind of insight that either clicks immediately or costs you 20 minutes of thrashing. StealthCoder hedges that moment.

Pattern tags

The honest play

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

Maximum Equal Frequency recycles across companies for a reason. It's hard-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. Made by a working FAANG engineer who treats the OA the way companies treat hiring: as a game with rules you should know. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Maximum Equal Frequency interview FAQ

Is this problem really asked at American Express and other finance companies?+

Yes, American Express has reportedly asked it. It's not a household name problem like LeetCode's most-seen questions, but it appears in technical loops at certain larger companies. The hard difficulty and low acceptance rate suggest it's asked less frequently, but when it does appear, you're expected to solve it efficiently.

What's the main trick that most candidates miss?+

Most people try to validate every possible prefix by recounting all frequencies from scratch. The real trick is recognizing that only a few frequency patterns are ever valid (all equal, all but one equal, single element, etc.) and checking those in constant time using a frequency-of-frequencies map. Once you spot that, the solution becomes straightforward.

How does the Array topic connect to Hash Table here?+

You iterate through the array once, but the heavy lifting is hash table operations: tracking element frequencies and the distribution of those frequencies. The array is just the input wrapper. The real problem is in the hash table state management and recognizing which states are valid.

What's a common pitfall that kills performance?+

Revalidating the entire frequency distribution at each index by rebuilding or recounting. That's O(n^2) at minimum. You need to maintain frequency counts incrementally and track how many elements share each frequency count, checking validity in O(1) per step.

How much time should I spend before I get stuck and need help?+

If you understand the problem clearly but can't see the frequency-pattern insight after 10 to 12 minutes, you're likely grinding the wrong approach. That's the moment to reset or call in a safety net. With the right pattern, the code writes itself in 5 minutes.

Want the actual problem statement? View "Maximum Equal 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.