← Back to challenges

Make Anagram

JavaScriptHardformattingstrings

Instructions

Given two strings, that may or may not be of the same length, determine the minimum number of character deletions required to make an anagram. Any characters can be deleted from either of the strings.

Examples

makeAnagram("cde", "abc") ➞ 4
// Remove d and e from cde to get c.
// Remove a and b from abc to get c.
// It takes 4 deletions to make both strings anagrams.

makeAnagram("fcrxzwscanmligyxyvym", "jxwtrhvujlmrpdoqbisbwhmgpmeoke") ➞ 30

makeAnagram("showman", "woman") ➞ 2

Notes

N/A

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.