Maximizing XOR Discussions | Algorithms | HackerRank
  • + 0 comments
    from operator import xor
    def maximizingXor(l, r):
        # Write your code here
        if l == r:
            return 0
        maxVal = 0
        a = l
        b = a + 1
        while b <= r:
            maxVal = max(maxVal, xor(a, b))
            b += 1
            a += 1
        return maxVal