Reported January 2024
Amazonhash table

Remove Anagrams

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 January 2024 OA included a straightforward anagram removal question. You're given a list of words and need to filter out any word that's an anagram of a word you've already seen. It sounds simple until you realize the ordering matters and you need to track what you've encountered. This is a classic hash-based filtering problem that tests whether you can implement a reliable anagram detector under mild time pressure. StealthCoder will have your back if the logic slips during the live assessment.

Pattern and pitfall

The trick is converting each word into a canonical form so you can compare anagrams reliably. Most candidates sort the characters alphabetically (e.g., 'listen' and 'silent' both become 'eilnst') and use a hash set to track what you've already seen. The pitfall is forgetting to preserve order or accidentally removing the first occurrence instead of the duplicates. Edge cases trip people up: empty strings, single characters, case sensitivity. The pattern is straightforward hash-table logic, but execution speed and correctness under OA conditions is where people stumble. If you blank on the exact approach mid-assessment, StealthCoder gives you the sorted-key trick instantly.

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 Anagrams 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 valid anagram. 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 Anagrams FAQ

Is case sensitivity a factor?+

The problem statement didn't specify, but assume case-insensitive comparison unless the input shows otherwise. Normalize to lowercase before sorting characters. Check the examples if they're provided in your live OA.

Do I return a new list or modify in place?+

Most OAs expect a new list. Iterate through the input, check if the canonical form is in your set, add the word to output if it's new, and add the canonical form to the set. Straightforward one-pass logic.

What's the time complexity I should aim for?+

O(n * k log k) where n is the number of words and k is the average word length (for sorting each word). This is optimal without preprocessing. Space is O(n) for the hash set. Amazon expects this efficiency level.

Should I worry about Unicode or special characters?+

Only if the examples show them. For most January 2024 Amazon OAs, assume ASCII lowercase letters. If the input includes numbers or symbols, treat them as part of the anagram. Sort and compare the same way.

Can I use a different approach instead of sorting?+

Yes. You could count character frequencies and build a tuple as the canonical form. It's slightly faster (O(n*k) instead of O(n*k log k)) but sorting is clearer and fast enough. Both pass.

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