Given two strings s1 and s2, we need to find the minimum number of manipulations required to make two strings anagram without deleting any character.
Note:- The anagram strings have same set of characters, sequence of characters can be different.
If deletion of character is allowed and cost is given, refer to Minimum Cost To Make Two Strings Identical
Question Source: Yatra.com Interview Experience | Set 7
Input : s1 = "aba" s2 = "baa" Output : 0 Explanation: Both String contains identical characters Input : s1 = "ddcf" s2 = "cedk" Output : 2 Explanation : Here, we need to change two characters in either of the strings to make them identical. We can change 'd' and 'f' in s1 or 'e' and 'k' in s2.
Assumption: Length of both the Strings is considered similar
Time Complexity : O(n), where n is the length of the string.
This article is contributed by Sumit Ghosh. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Using Counter() in Python to find minimum character removal to make two strings anagram
- Minimum number of pairs required to make two strings same
- Minimum number of operations required to make two strings equal
- Minimum number of given operations required to make two strings equal
- Find the minimum number of preprocess moves required to make two strings equal
- Remove minimum number of characters so that two strings become anagram
- Number of character corrections in the given strings to make them equal
- Minimum number of swaps required to make the string K periodic
- Least number of manipulations needed to ensure two strings have identical characters
- Minimum characters required to make a password strong
- Minimum operation require to make first and last character same
- Minimum swaps required to make a binary string alternating
- Minimum swaps required to make a binary string divisible by 2^k
- Minimum operations required to make the string satisfy the given condition
- Minimum number of adjacent swaps to convert a string into its given anagram
- Minimum addition/removal of characters to be done to make frequency of each character prime
- Minimum cost to make two strings same
- Minimum Cost To Make Two Strings Identical
- Minimum Cost to make two Numeric Strings Identical
- Minimum characters to be deleted from the end to make given two strings equal