Reported April 2025
Amazonhash table

Remove Characters in Frequency Order

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

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

Amazon's April 2025 OA is asking you to remove characters based on their frequency order. You've got a string, you need to figure out which characters appear most often, then strip them out in that order. It's a hash-table problem, but the twist is in how you sort and apply the removals. This is the kind of problem where candidates either nail it in 10 minutes or spend 25 minutes debugging the sort logic. StealthCoder catches you if you blank on the sorting step during the actual assessment.

Pattern and pitfall

The pattern here is straightforward hash-table work with a sorting hook. Count character frequencies, sort characters by frequency (descending or ascending depending on the problem spec), then iterate through that sorted order removing characters from the original string. Common pitfall: candidates forget that you're removing characters by frequency rank, not by value. They'll count correctly but then apply the removals in the wrong order. Another trap: string immutability in some languages means you need to rebuild the string instead of mutating it. The actual pattern is count-sort-filter. StealthCoder reads the exact problem text on your screen during the OA and can guide you through the sort order instantly if you get stuck between 'highest frequency first' and 'lowest frequency first'.

The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.

If this hits your live OA

You can drill Remove Characters in Frequency Order 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 for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as top k frequent elements. If you have time before the OA, drill that.

⏵ The honest play

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

Amazon reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Remove Characters in Frequency Order FAQ

What does 'remove in frequency order' actually mean?+

You count how often each character appears, sort those characters by their count (highest to lowest or vice versa depending on the problem wording), then remove them from the string in that sorted order. Not by alphabetical order, by frequency rank.

Is this really just a hash map and a sort?+

Yes. Hash map to count, sort the characters by frequency, then iterate and rebuild the string without the characters in removal order. If you can do that in your head, you're done in under 10 minutes.

What's the trick Amazon is looking for here?+

They want to see if you handle the sort correctly and rebuild the string efficiently. Some candidates try to mutate the original string in-place, which is messy. Build a new one. Also double-check the sort order before you code.

How do I prepare for this in 24 hours?+

Know how to count character frequencies in your language, how to sort a dictionary/map by values, and how to rebuild a string by filtering. Those three skills cover 90 percent of the solution.

Will Amazon ask a harder variant of this?+

Possibly. They might ask you to remove k most frequent characters, or return the string in a specific order. The core is the same, so nail the base version and the variants are just conditional logic on top.

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

OA at Amazon?
Invisible during screen share
Get it