Largest value of K that a set of all possible subset | Function to find maximum count of consecutive integers from 0 in set S of all possible subset - sum ; Stores the maximum possible integer ; Sort the given array in non - decrasing order ; Iterate the given array ; If arr [ i ] <= X + 1 , then update X otherwise break the loop ; Return Answer ; Driver Code
def maxConsecutiveCnt ( arr ) : NEW_LINE INDENT X = 0 NEW_LINE arr . sort ( ) NEW_LINE for i in range ( 0 , len ( arr ) ) : NEW_LINE INDENT if ( arr [ i ] <= ( X + 1 ) ) : NEW_LINE INDENT X = X + arr [ i ] NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT return X + 1 NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT arr = [ 1 , 1 , 1 , 4 ] NEW_LINE print ( maxConsecutiveCnt ( arr ) ) NEW_LINE DEDENT