mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-10-21 21:16:45 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>给定一个整数数据流和一个窗口大小,根据该滑动窗口的大小,计算滑动窗口里所有数字的平均值。</p>\n\n<p>实现 <code>MovingAverage</code> 类:</p>\n\n<ul>\n\t<li><code>MovingAverage(int size)</code> 用窗口大小 <code>size</code> 初始化对象。</li>\n\t<li><code>double next(int val)</code> 成员函数 <code>next</code> 每次调用的时候都会往滑动窗口增加一个整数,请计算并返回数据流中最后 <code>size</code> 个值的移动平均值,即滑动窗口里所有数字的平均值。</li>\n</ul>\n\n<p> </p>\n\n<p><strong>示例:</strong></p>\n\n<pre>\n<strong>输入:</strong>\ninputs = ["MovingAverage", "next", "next", "next", "next"]\ninputs = [[3], [1], [10], [3], [5]]\n<strong>输出:</strong>\n[null, 1.0, 5.5, 4.66667, 6.0]\n\n<strong>解释:</strong>\nMovingAverage movingAverage = new MovingAverage(3);\nmovingAverage.next(1); // 返回 1.0 = 1 / 1\nmovingAverage.next(10); // 返回 5.5 = (1 + 10) / 2\nmovingAverage.next(3); // 返回 4.66667 = (1 + 10 + 3) / 3\nmovingAverage.next(5); // 返回 6.0 = (10 + 3 + 5) / 3\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 <= size <= 1000</code></li>\n\t<li><code>-10<sup>5</sup> <= val <= 10<sup>5</sup></code></li>\n\t<li>最多调用 <code>next</code> 方法 <code>10<sup>4</sup></code> 次</li>\n</ul>\n\n<p> </p>\n\n<p><meta charset=\"UTF-8\" />注意:本题与主站 346 题相同: <a href=\"https://leetcode-cn.com/problems/moving-average-from-data-stream/\">https://leetcode-cn.com/problems/moving-average-from-data-stream/</a></p>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Easy",
|
||||
"likes": 18,
|
||||
"likes": 19,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -162,7 +162,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"11.8K\", \"totalSubmission\": \"15.2K\", \"totalAcceptedRaw\": 11796, \"totalSubmissionRaw\": 15189, \"acRate\": \"77.7%\"}",
|
||||
"stats": "{\"totalAccepted\": \"13.8K\", \"totalSubmission\": \"17.8K\", \"totalAcceptedRaw\": 13838, \"totalSubmissionRaw\": 17822, \"acRate\": \"77.6%\"}",
|
||||
"hints": [],
|
||||
"solution": null,
|
||||
"status": null,
|
||||
|
Reference in New Issue
Block a user