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.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- 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 given operations required to make two strings equal
- Minimum number of 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 characters to be deleted from the end to make given two strings equal
- Minimum move to end operations to make all strings equal