1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-10-22 05:26:46 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2022-05-02 23:44:12 +08:00
parent 7ea03594b3
commit 2a71c78585
4790 changed files with 11696 additions and 10944 deletions

View File

@@ -12,7 +12,7 @@
"translatedContent": "<p>请你实现三个 API <code>append</code><code>addAll</code> 和 <code>multAll</code> 来实现奇妙序列。</p>\n\n<p>请实现 <code>Fancy</code> 类 </p>\n\n<ul>\n\t<li><code>Fancy()</code> 初始化一个空序列对象。</li>\n\t<li><code>void append(val)</code> 将整数 <code>val</code> 添加在序列末尾。</li>\n\t<li><code>void addAll(inc)</code> 将所有序列中的现有数值都增加 <code>inc</code> 。</li>\n\t<li><code>void multAll(m)</code> 将序列中的所有现有数值都乘以整数 <code>m</code> 。</li>\n\t<li><code>int getIndex(idx)</code> 得到下标为 <code>idx</code> 处的数值(下标从 0 开始),并将结果对 <code>10<sup>9</sup> + 7</code> 取余。如果下标大于等于序列的长度,请返回 <code>-1</code> 。</li>\n</ul>\n\n<p> </p>\n\n<p><strong>示例:</strong></p>\n\n<pre>\n<strong>输入:</strong>\n[\"Fancy\", \"append\", \"addAll\", \"append\", \"multAll\", \"getIndex\", \"addAll\", \"append\", \"multAll\", \"getIndex\", \"getIndex\", \"getIndex\"]\n[[], [2], [3], [7], [2], [0], [3], [10], [2], [0], [1], [2]]\n<strong>输出:</strong>\n[null, null, null, null, null, 10, null, null, null, 26, 34, 20]\n\n<strong>解释:</strong>\nFancy fancy = new Fancy();\nfancy.append(2); // 奇妙序列:[2]\nfancy.addAll(3); // 奇妙序列:[2+3] -> [5]\nfancy.append(7); // 奇妙序列:[5, 7]\nfancy.multAll(2); // 奇妙序列:[5*2, 7*2] -> [10, 14]\nfancy.getIndex(0); // 返回 10\nfancy.addAll(3); // 奇妙序列:[10+3, 14+3] -> [13, 17]\nfancy.append(10); // 奇妙序列:[13, 17, 10]\nfancy.multAll(2); // 奇妙序列:[13*2, 17*2, 10*2] -> [26, 34, 20]\nfancy.getIndex(0); // 返回 26\nfancy.getIndex(1); // 返回 34\nfancy.getIndex(2); // 返回 20\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 <= val, inc, m <= 100</code></li>\n\t<li><code>0 <= idx <= 10<sup>5</sup></code></li>\n\t<li>总共最多会有 <code>10<sup>5</sup></code> 次对 <code>append</code><code>addAll</code><code>multAll</code> 和 <code>getIndex</code> 的调用。</li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Hard",
"likes": 49,
"likes": 51,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
@@ -149,7 +149,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"3.2K\", \"totalSubmission\": \"20.4K\", \"totalAcceptedRaw\": 3229, \"totalSubmissionRaw\": 20444, \"acRate\": \"15.8%\"}",
"stats": "{\"totalAccepted\": \"3.4K\", \"totalSubmission\": \"21.2K\", \"totalAcceptedRaw\": 3388, \"totalSubmissionRaw\": 21201, \"acRate\": \"16.0%\"}",
"hints": [
"Use two arrays to save the cumulative multipliers at each time point and cumulative sums adjusted by the current multiplier.",
"The function getIndex(idx) ask to the current value modulo 10^9+7. Use modular inverse and both arrays to calculate this value."