Decode XORed Array LeetCode solution in Java

1
class Solution {
2
public int[] decode(int[] encoded, int first) {
3
int[] ans = new int[encoded.length + 1];
4
ans[0] = first;
5
for (int i = 0; i < encoded.length; i++) {
6
ans[i + 1] = ans[i] ^ encoded[i];
7
}
8
return ans;
9
}
10
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0