Given two strings return the value of least number of manipulations needed to ensure both strings have identical characters, i.e., both string become anagram of each other.
Input : s1 = "aab" s2 = "aba" Output : 2 Explanation : string 1 contains 2 a's and 1 b, also string 2 contains same characters Input : s1 = "abc" s2 = "cdd" Output : 2 Explanation : string 1 contains 1 a, 1 b, 1 c while string 2 contains 1 c and 2 d's so there are 2 different characters
Question Source : Yatra.com Interview Experience | Set 7
The idea is to create a extra count array for both the strings separately and then count the difference in characters.
This article is contributed by Mandeep Singh. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Minimum Number of Manipulations required to make two Strings Anagram Without Deletion of Character
- Reduce the string by removing K consecutive identical characters
- Recursive program to insert a star between pair of identical characters
- Count the Number of matching characters in a pair of strings
- Remove minimum number of characters so that two strings become anagram
- Find all strings formed from characters mapped to digits of a number
- Find the number of strings formed using distinct characters of a given string
- Minimum Cost To Make Two Strings Identical
- Minimum Cost to make two Numeric Strings Identical
- Minimum cost to make two strings identical by deleting the digits
- Strings formed from given characters without any consecutive repeating characters
- Minimum number of operations to move all uppercase characters before all lower case characters
- Replace minimal number of characters to make all characters pair wise distinct
- Permutation of a string with maximum number of characters greater than its adjacent characters
- Common characters in n strings