public class Solution {
public static short parity(long x) {
short result = 0; while (x != 0) {
result ^= 1; x &= (x - 1); // Drops the lowest set bit of x.
}
return result;
}
public static void main(String[] args) {
short result = parity(2);
System.out.println(result);
}
}
EPI3. Parity 2
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.