2433. Find The Original Array of Prefix Xor Medium
1/**
2 * [2433] Find The Original Array of Prefix Xor
3 *
4 * You are given an integer array pref of size n. Find and return the array arr of size n that satisfies:
5 *
6 * pref[i] = arr[0] ^ arr[1] ^ ... ^ arr[i].
7 *
8 * Note that ^ denotes the bitwise-xor operation.
9 * It can be proven that the answer is unique.
10 *
11 * <strong class="example">Example 1:
12 *
13 * Input: pref = [5,2,0,3,1]
14 * Output: [5,7,2,3,2]
15 * Explanation: From the array [5,7,2,3,2] we have the following:
16 * - pref[0] = 5.
17 * - pref[1] = 5 ^ 7 = 2.
18 * - pref[2] = 5 ^ 7 ^ 2 = 0.
19 * - pref[3] = 5 ^ 7 ^ 2 ^ 3 = 3.
20 * - pref[4] = 5 ^ 7 ^ 2 ^ 3 ^ 2 = 1.
21 *
22 * <strong class="example">Example 2:
23 *
24 * Input: pref = [13]
25 * Output: [13]
26 * Explanation: We have pref[0] = arr[0] = 13.
27 *
28 *
29 * Constraints:
30 *
31 * 1 <= pref.length <= 10^5
32 * 0 <= pref[i] <= 10^6
33 *
34 */
35pub struct Solution {}
36
37// problem: https://leetcode.com/problems/find-the-original-array-of-prefix-xor/
38// discuss: https://leetcode.com/problems/find-the-original-array-of-prefix-xor/discuss/?currentPage=1&orderBy=most_votes&query=
39
40// submission codes start here
41
42impl Solution {
43 pub fn find_array(pref: Vec<i32>) -> Vec<i32> {
44 vec![]
45 }
46}
47
48// submission codes end
49
50#[cfg(test)]
51mod tests {
52 use super::*;
53
54 #[test]
55 fn test_2433() {
56 }
57}
58
Back
© 2025 bowen.ge All Rights Reserved.