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
- Remove minimum number of characters so that two strings become anagram
- Recursive program to insert a star between pair of identical characters
- Find the number of strings formed using distinct characters of a given string
- Find all strings formed from characters mapped to digits of a number
- 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
- Replace minimal number of characters to make all characters pair wise distinct
- Minimum number of operations to move all uppercase characters before all lower case characters
- Permutation of a string with maximum number of characters greater than its adjacent characters
- Common characters in n strings
- Sub-strings having exactly k characters that have ASCII value greater than p
- Find uncommon characters of the two strings