2425. Bitwise XOR of All Pairings Medium

@problem@discussion
#Array#Bit Manipulation#Brainteaser



1/**
2 * [2425] Bitwise XOR of All Pairings
3 *
4 * You are given two 0-indexed arrays, nums1 and nums2, consisting of non-negative integers. There exists another array, nums3, which contains the bitwise XOR of all pairings of integers between nums1 and nums2 (every integer in nums1 is paired with every integer in nums2 exactly once).
5 * Return the bitwise XOR of all integers in nums3.
6 *  
7 * Example 1:
8 * 
9 * Input: nums1 = [2,1,3], nums2 = [10,2,5,0]
10 * Output: 13
11 * Explanation:
12 * A possible nums3 array is [8,0,7,2,11,3,4,1,9,1,6,3].
13 * The bitwise XOR of all these numbers is 13, so we return 13.
14 * 
15 * Example 2:
16 * 
17 * Input: nums1 = [1,2], nums2 = [3,4]
18 * Output: 0
19 * Explanation:
20 * All possible pairs of bitwise XORs are nums1[0] ^ nums2[0], nums1[0] ^ nums2[1], nums1[1] ^ nums2[0],
21 * and nums1[1] ^ nums2[1].
22 * Thus, one possible nums3 array is [2,5,1,6].
23 * 2 ^ 5 ^ 1 ^ 6 = 0, so we return 0.
24 * 
25 *  
26 * Constraints:
27 * 
28 * 	1 <= nums1.length, nums2.length <= 10^5
29 * 	0 <= nums1[i], nums2[j] <= 10^9
30 * 
31 */
32pub struct Solution {}
33
34// problem: https://leetcode.com/problems/bitwise-xor-of-all-pairings/
35// discuss: https://leetcode.com/problems/bitwise-xor-of-all-pairings/discuss/?currentPage=1&orderBy=most_votes&query=
36
37// submission codes start here
38
39impl Solution {
40    pub fn xor_all_nums(nums1: Vec<i32>, nums2: Vec<i32>) -> i32 {
41        0
42    }
43}
44
45// submission codes end
46
47#[cfg(test)]
48mod tests {
49    use super::*;
50
51    #[test]
52    fn test_2425() {
53    }
54}
55


Back
© 2025 bowen.ge All Rights Reserved.