Class Solution
java.lang.Object
g2401_2500.s2433_find_the_original_array_of_prefix_xor.Solution
2433 - Find The Original Array of Prefix Xor.<p>Medium</p>
<p>You are given an <strong>integer</strong> array <code>pref</code> of size <code>n</code>. Find and return <em>the array</em> <code>arr</code> <em>of size</em> <code>n</code> <em>that satisfies</em>:</p>
<ul>
<li><code>pref[i] = arr[0] ^ arr[1] ^ ... ^ arr[i]</code>.</li>
</ul>
<p>Note that <code>^</code> denotes the <strong>bitwise-xor</strong> operation.</p>
<p>It can be proven that the answer is <strong>unique</strong>.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> pref = [5,2,0,3,1]</p>
<p><strong>Output:</strong> [5,7,2,3,2]</p>
<p><strong>Explanation:</strong> From the array [5,7,2,3,2] we have the following:</p>
<ul>
<li>
<p>pref[0] = 5.</p>
</li>
<li>
<p>pref[1] = 5 ^ 7 = 2.</p>
</li>
<li>
<p>pref[2] = 5 ^ 7 ^ 2 = 0.</p>
</li>
<li>
<p>pref[3] = 5 ^ 7 ^ 2 ^ 3 = 3.</p>
</li>
<li>
<p>pref[4] = 5 ^ 7 ^ 2 ^ 3 ^ 2 = 1.</p>
</li>
</ul>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> pref = [13]</p>
<p><strong>Output:</strong> [13]</p>
<p><strong>Explanation:</strong> We have pref[0] = arr[0] = 13.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= pref.length <= 10<sup>5</sup></code></li>
<li><code>0 <= pref[i] <= 10<sup>6</sup></code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
findArray
public int[] findArray(int[] pref)
-