Loading...
You are given an integer array nums.
nums
For every subarray nums[l..r] (contiguous, l <= r), compute the XOR of its elements and multiply it by the subarray's length, (r - l + 1).
nums[l..r]
l <= r
(r - l + 1)
Return the sum of these products over all subarrays. Mod the result by 998244353.
998244353
Input: nums = [1,3,2] Output: 12 Explanation: Subarray XORs weighted by length: [1]→1·1, [1,3]→2·2, [1,3,2]→0·3, [3]→3·1, [3,2]→1·2, [2]→2·1. Total = 1+4+0+3+2+2 = 12.
Input: nums = [1,2] Output: 9 Explanation: 1·1 + 3·2 + 2·1 = 9.
nums.length
nums[i]
Click "Run" to test with sample cases or "Submit" to run all tests.