Maximizing XOR Discussions | Algorithms | HackerRank
  • + 1 comment

    sir can you explain how the below solution is solving this problem.

    def maxXOR(L,R): P = L^R ret = 1 while(P): # this one takes (m+1) = O(logR) steps ret <<= 1 P >>= 1 return (ret - 1)

    i dont understand that how we are getting right answer by doing this method.