Numbers that are bitwise AND of at least one non | Python3 implementation of the approach ; Set to store all possible AND values . ; Starting index of the sub - array . ; Ending index of the sub - array . res = 2147483647 Integer . MAX_VALUE ; AND value is added to the set . ; The set contains all possible AND values .
A = [ 11 , 15 , 7 , 19 ] NEW_LINE N = len ( A ) NEW_LINE Set = set ( ) NEW_LINE for i in range ( 0 , N ) : NEW_LINE INDENT for j in range ( i , N ) : NEW_LINE INDENT res &= A [ j ] NEW_LINE Set . add ( res ) NEW_LINE DEDENT DEDENT print ( Set ) NEW_LINE