-
-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
10 additions
and
0 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
coding_interviews/leetcode/medium/find-the-original-array-of-prefix-xor/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Find The Original Array of Prefix Xor | ||
|
||
[Problem link](https://leetcode.com/problems/find-the-original-array-of-prefix-xor) | ||
|
||
- If you want `5 ^ ? = 2`, you can do a reverse xor using `5 ^ 2 = ?`, which in this case `? = 7` | ||
- If you want to do consecutive XOR operations like `5 ^ 7 ^ 2 ^ 3 ^ 2`, you can replace that with the previous `pref` item | ||
- e.g. `5 ^ 7 ^ ? = 0.`, you want to find `?` | ||
- so you need to do `5 ^ 7 ^ 0 = ?` but at that point, if you don't store the previous result, you don't have `5 ^ 7` | ||
- but you can get this calculation from the previous `pref` item because it can replace `5 ^ 7`, in this case, it is `2` | ||
- Runtime complexity: O(N), where N is prev.length |