题解 | #牛的编号异或问题#
牛的编号异或问题
https://www.nowcoder.com/practice/b8139d2af0f64e6489f69cb173f170c1
class Solution {
public:
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param left int整型
* @param right int整型
* @return int整型
*/
int rangeBitwiseXor(int left, int right) {
// write code here
for(int i=left+1;i<=right;i++){
left^=i;
}
return left;
}
};