Skip to content

Commit 95da6a2

Browse files
authored
Create Find The Original Array of Prefix Xor.java
1 parent d3a4486 commit 95da6a2

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Solution {
2+
public int[] findArray(int[] pref) {
3+
int n = pref.length;
4+
int[] result = new int[n];
5+
result[0] = pref[0];
6+
for (int i = 1; i < n; i++) {
7+
result[i] = pref[i] ^ pref[i - 1];
8+
}
9+
return result;
10+
}
11+
}

0 commit comments

Comments
 (0)