We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
static long getXor(long x)
{
long n = x % 8;
if (n == 0 || n == 1) return x;
if (n == 2 || n == 3) return 2;
if (n == 4 || n == 5) return x + 2;
return 0;
}
// Complete the xorSequence function below.
static long xorSequence(long l, long r) {
return getXor(r) ^ getXor(l - 1);
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Xor-sequence
You are viewing a single comment's thread. Return to all comments →
In C#:
class Solution {