Minimum number of deletions so that no two consecutive are same | Function for counting deletions ; If two consecutive characters are the same , delete one of them . ; Driver code ; Function call to print answer
def countDeletions ( string ) : NEW_LINE INDENT ans = 0 NEW_LINE for i in range ( len ( string ) - 1 ) : NEW_LINE INDENT if ( string [ i ] == string [ i + 1 ] ) : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT string = " AAABBB " NEW_LINE print countDeletions ( string ) NEW_LINE