We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
You are supposed to eliminate the common characters between 2 strings and sum up (not increment) absolute values of occurrences of other characters in both strings
For example, if A = "abe" and B = "aabc", resulting hashmap would be like this { 'a': -1, 'b': 0, 'c': 1, 'e': 1 }
Sum of absolute values of hashmap gives 3 and this shows that we must delete 3 characters ('a', 'c' and 'e' - 1 occurrence each) from strings A and B to make them anagrams.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Strings: Making Anagrams
You are viewing a single comment's thread. Return to all comments →
Change this
to this
You are supposed to eliminate the common characters between 2 strings and sum up (not increment) absolute values of occurrences of other characters in both strings
For example, if A = "abe" and B = "aabc", resulting hashmap would be like this { 'a': -1, 'b': 0, 'c': 1, 'e': 1 }
Sum of absolute values of hashmap gives 3 and this shows that we must delete 3 characters ('a', 'c' and 'e' - 1 occurrence each) from strings A and B to make them anagrams.