Skip to content

Practice Handling Sum Queries After Update

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#2569
LeetCode Problem

Handling Sum Queries After Update

Problem Statement

Process queries in order on nums1 and nums2. [1,l,r] flips every bit of nums1 from l through r inclusive. [2,p,0] adds p * nums1[i] to nums2[i] for every index i, using the current nums1. [3,0,0] reports the current sum of nums2. Return only those reports, in order.

Source: Handling Sum Queries After Update on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums1 = [1,0,1], nums2 = [0,0,0], queries = [[1,1,1],[2,1,0],[3,0,0]]
Output
[3]

# Example 2

Input
nums1 = [1], nums2 = [5], queries = [[2,0,0],[3,0,0]]
Output
[5]

Constraints

1 <= nums1.length,nums2.length <= 10^5
nums1.length = nums2.length
1 <= queries.length <= 10^5
queries[i].length = 3
0 <= l <= r <= nums1.length - 1
0 <= p <= 10^6
0 <= nums1[i] <= 1
0 <= nums2[i] <= 10^9

Related LeetCode Problems

Practice more problems similar to Handling Sum Queries After Update.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.