Minimum characters to be deleted from the end to make given two strings equal | C # program to count minimum number of characters to be deleted to make the strings equal ; Function that finds minimum character required to be deleted ; Iterate in the strings ; Check if the characters are not equal ; Return the result ; Driver code
using System ; class GFG { static int minDel ( String s1 , String s2 ) { int i = 0 ; while ( i < Math . Min ( s1 . Length , s2 . Length ) ) { if ( s1 [ i ] != s2 [ i ] ) { break ; } i ++ ; } int ans = ( ( s1 . Length - i ) + ( s2 . Length - i ) ) ; return ans ; } public static void Main ( String [ ] args ) { String s1 = " geeks " ; String s2 = " geeksfor " ; Console . WriteLine ( minDel ( s1 , s2 ) ) ; } }