Remove Anagram π
Learn this problemProblem statement
A collection of distinct item identifiers must be retrieved from a repository of merchandise listed on Amazonβs platform. In the dataset, duplicate variations of the item IDs exist where the sequence of letters differs (e.g., "code" and "ecode" refer to the same product). To generate the unique set, all anagram duplicates should be eliminated. Two words are considered anagrams if they contain the same characters in the same frequencies, just arranged differently. For instance, "aaagmnrs" is an anagram of "anagrams". Given an array of strings, filter out every entry that is an anagram of a preceding entry, then provide the resultant list in alphabetically sorted order.
Design a method that returns the refined list of strings after discarding anagram duplicates in sorted sequence.
Function
removeAnagram(inputStrings: String[]) β String[]
Complete the function removeAnagram in the editor below.
removeAnagram has the following parameter:
inputStrings, a list of strings representing product IDs.
Returns
String Array
Note: Each string inputString[i] is made up of characters in the range ASCII[a-z].
Examples
Example 1
inputStrings = ["code", "doce", "ecod", "framer", "frame"]return = ["code", "frame", "framer"]Constraints
More Amazon problems
- Secure Maximum DeliveriesOA Β· Seen Jul 2026
- Find Median from Data StreamONSITE INTERVIEW Β· Seen Jul 2026
- Handwritten SigmoidPHONE SCREEN Β· Seen Jul 2026
- Handwritten SoftmaxPHONE SCREEN Β· Seen Jul 2026
- Koko Eating BananasONSITE INTERVIEW Β· Seen Jul 2026
- Loyal Customers Across Two DaysONSITE INTERVIEW Β· Seen Jul 2026
- Maximum System Memory CapacityOA Β· Seen Jul 2026
- Package Delivery SystemOA Β· Seen Jul 2026