Update the answer with the number of elements between non - consecutive occurrences of the given letter
ans = ans + cnt ; NEW_LINE cnt = 0 ; NEW_LINE while ( i < len ( string ) and string [ i ] != k ) : NEW_LINE INDENT i = i + 1 ; NEW_LINE DEDENT