1835. Find XOR Sum of All Pairs Bitwise AND Hard

@problem@discussion
#Array#Math#Bit Manipulation



1/**
2 * [1835] Find XOR Sum of All Pairs Bitwise AND
3 *
4 * The XOR sum of a list is the bitwise XOR of all its elements. If the list only contains one element, then its XOR sum will be equal to this element.
5 * 
6 * 	For example, the XOR sum of [1,2,3,4] is equal to 1 XOR 2 XOR 3 XOR 4 = 4, and the XOR sum of [3] is equal to 3.
7 * 
8 * You are given two 0-indexed arrays arr1 and arr2 that consist only of non-negative integers.
9 * Consider the list containing the result of arr1[i] AND arr2[j] (bitwise AND) for every (i, j) pair where 0 <= i < arr1.length and 0 <= j < arr2.length.
10 * Return the XOR sum of the aforementioned list.
11 *  
12 * Example 1:
13 * 
14 * Input: arr1 = [1,2,3], arr2 = [6,5]
15 * Output: 0
16 * Explanation: The list = [1 AND 6, 1 AND 5, 2 AND 6, 2 AND 5, 3 AND 6, 3 AND 5] = [0,1,2,0,2,1].
17 * The XOR sum = 0 XOR 1 XOR 2 XOR 0 XOR 2 XOR 1 = 0.
18 * 
19 * Example 2:
20 * 
21 * Input: arr1 = [12], arr2 = [4]
22 * Output: 4
23 * Explanation: The list = [12 AND 4] = [4]. The XOR sum = 4.
24 * 
25 *  
26 * Constraints:
27 * 
28 * 	1 <= arr1.length, arr2.length <= 10^5
29 * 	0 <= arr1[i], arr2[j] <= 10^9
30 * 
31 */
32pub struct Solution {}
33
34// problem: https://leetcode.com/problems/find-xor-sum-of-all-pairs-bitwise-and/
35// discuss: https://leetcode.com/problems/find-xor-sum-of-all-pairs-bitwise-and/discuss/?currentPage=1&orderBy=most_votes&query=
36
37// submission codes start here
38
39impl Solution {
40    pub fn get_xor_sum(arr1: Vec<i32>, arr2: 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_1835() {
53    }
54}
55


Back
© 2025 bowen.ge All Rights Reserved.