LeetCode - Algorithms - 1486. XOR Operation in an Array

Problem

1486. XOR Operation in an Array

Java

1
2
3
4
5
6
7
8
9
10
class Solution {
public int xorOperation(int n, int start) {
int r = start;
for (; n > 1; n--) {
start += 2;
r = r ^ start;
}
return r;
}
}

Submission Detail

  • 54 / 54 test cases passed.
  • Runtime: 0 ms, faster than 100.00% of Java online submissions for XOR Operation in an Array.
  • Memory Usage: 38.3 MB, less than 100.00% of Java online submissions for XOR Operation in an Array.