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.
This method counts for differences on both strings, so the answer needs to be reduced by half since the question asks how many times ONE string needs to be modified to match the other. For example, with string "aaabbb", this method concludes that "aaa" doesn't match "bbb" and that "bbb" doesn't match "aaa", implying that 6 letters need to be modified for them to equal somehow (i.e. cccccc). However we just need one string to transform into another, so really only 3 letters need to be modified (i.e. "aaa" from first string becomes "bbb", thus matching the second).
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Anagram
You are viewing a single comment's thread. Return to all comments →
This method counts for differences on both strings, so the answer needs to be reduced by half since the question asks how many times ONE string needs to be modified to match the other. For example, with string "aaabbb", this method concludes that "aaa" doesn't match "bbb" and that "bbb" doesn't match "aaa", implying that 6 letters need to be modified for them to equal somehow (i.e. cccccc). However we just need one string to transform into another, so really only 3 letters need to be modified (i.e. "aaa" from first string becomes "bbb", thus matching the second).