Traverse the string S to find the frequency of 1 and 0
for i in range ( 0 , len ( s ) ) : NEW_LINE INDENT if ( s [ i ] == '1' ) : NEW_LINE INDENT tot_ones += 1 NEW_LINE DEDENT else : NEW_LINE INDENT tot_zeros += 1 NEW_LINE DEDENT DEDENT