P19863 [GeeksforGeeks] Xor count zero and one2724
普及-
题目描述

Given a number N, the task is to find XOR of count of 0s and count of 1s in binary representation of a given number.

Example 1:
Input: N = 5
Output: 3
Explanation:
Binary representation: 101
Set_bit_count: 2
Unset_bit_count: 1
2 XOR 1 = 3
Example 2:
Input: N = 7
Output: 3
Expalanation:
Binary representation: 111
Set_bit_count: 3
Unset_bit_count: 0
3 XOR 0 = 3
Your Task:
You don't need to read or print anything. Your task is to complete the function find_xor() which takes N as input parameter and returns the XOR of count of 0s and count of 1s in binary representation of N.
Expected Time Complexity: O(log(N))
Expected Space Complexity: O(1)
Constranits:
1 <= N <= 10^{9}

输入格式

见题面

输出格式

见题面

样例输入
N = 5
样例输出
3