• + 0 comments
    def bitwiseAnd(N, K):
        
        max_A_and_B = 0
        
        for A in range(1, N):
            for B in range(A+1, N+1):
                A_and_B = A & B
                if (A_and_B > max_A_and_B) and (A_and_B < K):
                    max_A_and_B = A_and_B
    
        return max_A_and_B