代码拉取完成,页面将自动刷新
同步操作将从 小墨/力扣题库(完整版) 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
<p>You are given two <strong>0-indexed</strong> arrays <code>nums1</code> and <code>nums2</code> and a 2D array <code>queries</code> of queries. There are three types of queries:</p>
<ol>
<li>For a query of type 1, <code>queries[i] = [1, l, r]</code>. Flip the values from <code>0</code> to <code>1</code> and from <code>1</code> to <code>0</code> in <code>nums1 </code>from index <code>l</code> to index <code>r</code>. Both <code>l</code> and <code>r</code> are <strong>0-indexed</strong>.</li>
<li>For a query of type 2, <code>queries[i] = [2, p, 0]</code>. For every index <code>0 <= i < n</code>, set <code>nums2[i] = nums2[i] + nums1[i] * p</code>.</li>
<li>For a query of type 3, <code>queries[i] = [3, 0, 0]</code>. Find the sum of the elements in <code>nums2</code>.</li>
</ol>
<p>Return <em>an array containing all the answers to the third type queries.</em></p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</strong> nums1 = [1,0,1], nums2 = [0,0,0], queries = [[1,1,1],[2,1,0],[3,0,0]]
<strong>Output:</strong> [3]
<strong>Explanation:</strong> After the first query nums1 becomes [1,1,1]. After the second query, nums2 becomes [1,1,1], so the answer to the third query is 3. Thus, [3] is returned.
</pre>
<p><strong class="example">Example 2:</strong></p>
<pre>
<strong>Input:</strong> nums1 = [1], nums2 = [5], queries = [[2,0,0],[3,0,0]]
<strong>Output:</strong> [5]
<strong>Explanation:</strong> After the first query, nums2 remains [5], so the answer to the second query is 5. Thus, [5] is returned.
</pre>
<p> </p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= nums1.length,nums2.length <= 10<sup>5</sup></code></li>
<li><code>nums1.length = nums2.length</code></li>
<li><code>1 <= queries.length <= 10<sup>5</sup></code></li>
<li><code><font face="monospace">queries[i].length = 3</font></code></li>
<li><code><font face="monospace">0 <= l <= r <= nums1.length - 1</font></code></li>
<li><code><font face="monospace">0 <= p <= 10<sup>6</sup></font></code></li>
<li><code>0 <= nums1[i] <= 1</code></li>
<li><code>0 <= nums2[i] <= 10<sup>9</sup></code></li>
</ul>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。