Anagram difference

Given two List of strings a and b, we need to find the minimum number of manipulations required to make each two strings anagram from the two lists.

Input : 
a = "a", "jk", "abb", "mn", "abc"
b= "bb", "kj", "bbc", "op", "def"
Output : [ -1, 0, 1, 2, 3]
Explanation: Both String contains identical characters

Input :
s1 = "a"
s2 = "bb"
Output : -1
Explanation : As the length of both the strings are not same op is -1.
Input :
s1 = "jk"
s2 = "kj"
Output : 0
Explanation : Both String contains identical characters.
Input :
s1 = "abb"
s2 = "bbc"
Output : 1
Explanation : Here, we need to change one character
in either of the strings to make them identical. We
can change 'a' and 'c' in s1 or 'c' and 'a' in s2.
Input :
s1 = "mn"
s2 = "op"
Output : 2
Input :
s1 = "abc"
s2 = "def"
Output : 3

Time Complexity: O(n), where n is the length of the string.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store