image_2021-11-01_04-03-50.png
26.6 KB
#N1486. XOR Operation in an Array
problem link=>https://leetcode.com/problems/xor-operation-in-an-array/
#solution
problem link=>https://leetcode.com/problems/xor-operation-in-an-array/
#solution
class Solution {
public int xorOperation(int n, int start) {
int ans=0;
while(n-- > 0){
ans ^= start;
start+=2;
}
return ans;
}
}