If count of characters used from a particular group of characters has not exceeded m
else : NEW_LINE INDENT low = indexes [ it ] + 1 NEW_LINE DEDENT return True NEW_LINE def lower_bound ( indexes , k ) : NEW_LINE low , high = 0 , len ( indexes ) - 1 NEW_LINE while ( low < high ) : NEW_LINE mid = ( low + high ) // 2 NEW_LINE if ( indexes [ mid ] < k ) : NEW_LINE INDENT low = mid + 1 NEW_LINE DEDENT else : NEW_LINE INDENT high = mid NEW_LINE DEDENT if indexes [ low ] < k : NEW_LINE return ( low + 1 ) NEW_LINE else : NEW_LINE return low NEW_LINE