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 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.
- Minimum Number of Manipulations required to make two Strings Anagram Without Deletion of Character
- Yatra.com Interview Experience | Set 10
- Yatra.com Interview Experience | Set 9 (On-Campus for Software Developer)
- Yatra.com Interview Experience | Set 8 (On-Campus for Software Developer )
- Repeatedly search an element by doubling it after every successful search
- Yatra.com Interview Experience | Set 6
- Yatra.com Interview Experience | Set 5 (For Software Developer 1)
- Yatra.com Interview Experience | Set 4
- Interview Experience with Yatra(Hyderabad) | Set 3 (For Senior Software Engineer)
- Yatra.com Interview | Set 2
- Yatra.com Interview | Set 1
- Rat in a Maze | Backtracking-2
- Sort an array of 0s, 1s and 2s
- Check for balanced parentheses in an expression