3653. XOR After Range Multiplication Queries I Medium
1/**
2 * [3653] XOR After Range Multiplication Queries I
3 *
4 * You are given an integer array nums of length n and a 2D integer array queries of size q, where queries[i] = [li, ri, ki, vi].
5 * For each query, you must apply the following operations in order:
6 *
7 * Set idx = li.
8 * While idx <= ri:
9 *
10 * Update: nums[idx] = (nums[idx] * vi) % (10^9 + 7)
11 * Set idx += ki.
12 *
13 *
14 *
15 * Return the bitwise XOR of all elements in nums after processing all queries.
16 *
17 * <strong class="example">Example 1:
18 * <div class="example-block">
19 * Input: <span class="example-io">nums = [1,1,1], queries = [[0,2,1,4]]</span>
20 * Output: <span class="example-io">4</span>
21 * Explanation:
22 *
23 * <li data-end="106" data-start="18">A single query <code data-end="44" data-start="33">[0, 2, 1, 4] multiplies every element from index 0 through index 2 by 4.
24 * <li data-end="157" data-start="109">The array changes from <code data-end="141" data-start="132">[1, 1, 1] to <code data-end="154" data-start="145">[4, 4, 4].
25 * <li data-end="205" data-start="160">The XOR of all elements is <code data-end="202" data-start="187">4 ^ 4 ^ 4 = 4.
26 * </div>
27 * <strong class="example">Example 2:
28 * <div class="example-block">
29 * Input: <span class="example-io">nums = [2,3,1,5,4], queries = [[1,4,2,3],[0,2,1,2]]</span>
30 * Output: <span class="example-io">31</span>
31 * Explanation:
32 *
33 * <li data-end="350" data-start="230">The first query <code data-end="257" data-start="246">[1, 4, 2, 3] multiplies the elements at indices 1 and 3 by 3, transforming the array to <code data-end="347" data-start="333">[2, 9, 1, 15, 4].
34 * <li data-end="466" data-start="353">The second query <code data-end="381" data-start="370">[0, 2, 1, 2] multiplies the elements at indices 0, 1, and 2 by 2, resulting in <code data-end="463" data-start="448">[4, 18, 2, 15, 4].
35 * <li data-end="532" data-is-last-node="" data-start="469">Finally, the XOR of all elements is <code data-end="531" data-start="505">4 ^ 18 ^ 2 ^ 15 ^ 4 = 31.
36 * </div>
37 *
38 * Constraints:
39 *
40 * 1 <= n == nums.length <= 10^3
41 * 1 <= nums[i] <= 10^9
42 * 1 <= q == queries.length <= 10^3
43 * queries[i] = [li, ri, ki, vi]
44 * 0 <= li <= ri < n
45 * 1 <= ki <= n
46 * 1 <= vi <= 10^5
47 *
48 */
49pub struct Solution {}
50
51// problem: https://leetcode.com/problems/xor-after-range-multiplication-queries-i/
52// discuss: https://leetcode.com/problems/xor-after-range-multiplication-queries-i/discuss/?currentPage=1&orderBy=most_votes&query=
53
54// submission codes start here
55
56impl Solution {
57 pub fn xor_after_queries(nums: Vec<i32>, queries: Vec<Vec<i32>>) -> i32 {
58 0
59 }
60}
61
62// submission codes end
63
64#[cfg(test)]
65mod tests {
66 use super::*;
67
68 #[test]
69 fn test_3653() {
70 }
71}
72Back
© 2026 bowen.ge All Rights Reserved.