Trains the technique from
LeetCode 3655XOR After Range Multiplication Queries IIThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A ledger holds entries nums. Each adjustment in queries is [l, r, k, v] and multiplies, modulo 10^9 + 7, the entries at positions l, l + k, l + 2k and onwards, as far as position r inclusive.
Both the ledger and the list of adjustments may run to a hundred thousand, so working every adjustment out entry by entry is far too slow.
Return the bitwise exclusive-or of the finished ledger.
Example 1
The single adjustment strides by two from position 1 and stops at position 4, so it reaches positions 1 and 3 only, tripling those two entries and leaving the rest as they were.
Example 2
The first adjustment strides by two from position 0, so it reaches position 0 alone and trebles the 5. The second multiplies position 1 by four.
Example 3
Both adjustments multiply by one, so the ledger is untouched.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def xor_after_queries(nums: list[int], queries: list[list[int]]) -> int:public int xorAfterQueries(int[] nums, int[][] queries)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.