Sum of minimum and the maximum difference between two given Strings | C # program to find the sum of the minimum and the maximum difference between two given Strings ; Function to find the sum of the minimum and the maximum difference between two given Strings ; Variables to store the minimum difference and the maximum difference ; Iterate through the length of the String as both the given Strings are of the same length ; For the maximum difference , we can replace " + " in both the Strings with different char ; For the minimum difference , we can replace " + " in both the Strings with the same char ; Driver code
using System ; class GFG { static void solve ( char [ ] a , char [ ] b ) { int l = a . Length ; int min = 0 , max = 0 ; for ( int i = 0 ; i < l ; i ++ ) { if ( a [ i ] == ' + ' b [ i ] == ' + ' a [ i ] != b [ i ] ) max ++ ; if ( a [ i ] != ' + ' && b [ i ] != ' + ' && a [ i ] != b [ i ] ) min ++ ; } Console . Write ( min + max + " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { String s1 = " a + c " , s2 = " + + b " ; solve ( s1 . ToCharArray ( ) , s2 . ToCharArray ( ) ) ; } }