[LeetCode] Handling Sum Queries After Update

2569. Handling Sum Queries After Update

You are given two 0-indexed arrays nums1 and nums2 and a 2D array queries of queries. There are three types of queries:

  1. For a query of type 1, queries[i] = [1, l, r]. Flip the values from 0 to 1 and from 1 to 0 in nums1 from index l to index r. Both l and r are 0-indexed.
  2. For a query of type 2, queries[i] = [2, p, 0]. For every index 0 <= i < n, set nums2[i] = nums2[i] + nums1[i] * p.
  3. For a query of type 3, queries[i] = [3, 0, 0]. Find the sum of the elements in nums2.

Return an array containing all the answers to the third type queries.

Read more
[AtCoder] G - SqrtRead more
[AtCoder] F - LotteryRead more
[AtCoder] D - Prefix XORsRead more
[AtCoder] C - Distinct NumbersRead more
[AtCoder] G - Construct Good PathRead more
[Codeforces] Manthan, Codefest 18 (rated, Div. 1 + Div. 2) D. Valid BFS?Read more
[Codeforces] Round #509 (Div. 2) D. GliderRead more
[Codeforces] Round #510 (Div. 2) C. Array ProductRead more
[Codeforces] Round #519 by Botan Investments D. Mysterious CrimeRead more