Given two strings S1 and S2 in lowercase, the task is to make them anagram. The only allowed operation is to remove a character from any string. Find the minimum number of characters to be deleted to make both the strings anagram. Two strings are called anagram of each other if one of them can be converted into another by rearranging its letters.
S1 = bcadeh
S2 = hea
Explanation: We need to remove b, c
and d from S1.
S1 = cddgk
S2 = gcd
Explanation: We need to remove d and
k from S1.
Your Task: Complete the function remAnagram() which takes two strings S1, S2 as input parameter, and returns minimum characters needs to be deleted.
Expected Time Complexity: O(max(|S1|, |S2|)), where |S| = length of string S. Expected Auxiliary Space: O(26)