Minimum Number of Manipulations required to make two Strings Anagram Without Deletion of Character | C # Program to find minimum number of manipulations required to make two strings identical ; Counts the no of manipulations required ; store the count of character ; iterate though the first String and update count ; iterate through the second string update char_count . if character is not found in char_count then increase count ; Driver code
using System ; public class GFG { static int countManipulations ( string s1 , string s2 ) { int count = 0 ; int [ ] char_count = new int [ 26 ] ; for ( int i = 0 ; i < s1 . Length ; i ++ ) char_count [ s1 [ i ] - ' a ' ] ++ ; for ( int i = 0 ; i < s2 . Length ; i ++ ) char_count [ s2 [ i ] - ' a ' ] -- ; for ( int i = 0 ; i < 26 ; ++ i ) { if ( char_count [ i ] != 0 ) { count += Math . Abs ( char_count [ i ] ) ; } } return count / 2 ; } public static void Main ( ) { string s1 = " ddcf " ; string s2 = " cedk " ; Console . WriteLine ( countManipulations ( s1 , s2 ) ) ; } }