Maximizing XOR Discussions | Algorithms | HackerRank
  • + 4 comments

    It is a nice solution. My solution is similar with no additional method calls.

    		int x = l ^ r;
    		int max = 0;
    		while(x > 0)
    		{
    			max <<= 1;
    			max |= 1;
    			x >>= 1;
    		}
            return max;