mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-10-21 13:06:47 +08:00
update
This commit is contained in:
@@ -12,12 +12,12 @@
|
||||
"translatedContent": "<p>现给定一个函数 <code>fn</code>,一个参数数组 <code>args</code> 和一个时间间隔 <code>t</code>,返回一个取消函数 <code>cancelFn</code>。</p>\n\n<p>在经过 <code>cancelTimeMs</code> 毫秒的延迟后,将调用返回的取消函数 <code>cancelFn</code>。</p>\n\n<pre>\nsetTimeout(cancelFn, cancelTimeMs)\n</pre>\n\n<p>函数 <code>fn</code> 应立即使用参数 <code>args</code> 调用,然后每隔 <code>t</code> 毫秒调用一次,直到在 <code>cancelTimeMs</code> 毫秒时调用 <code>cancelFn</code>。</p>\n\n<p> </p>\n\n<p><strong class=\"example\">示例 1:</strong></p>\n\n<pre>\n<b>输入:</b>fn = (x) => x * 2, args = [4], t = 35, cancelT = 190\n<b>输出:</b>\n[\n {\"time\": 0, \"returned\": 8},\n {\"time\": 35, \"returned\": 8},\n {\"time\": 70, \"returned\": 8},\n {\"time\": 105, \"returned\": 8},\n {\"time\": 140, \"returned\": 8},\n {\"time\": 175, \"returned\": 8}\n]\n<strong>解释:</strong> \nconst cancelTimeMs = 190;\nconst cancelFn = cancellable((x) => x * 2, [4], 35);\nsetTimeout(cancelFn, cancelTimeMs);\n\n每隔 35ms,调用 fn(4)。直到 t=190ms,然后取消。\n第一次调用 fn 是在 0ms。fn(4) 返回 8。\n第二次调用 fn 是在 35ms。fn(4) 返回 8。\n第三次调用 fn 是在 70ms。fn(4) 返回 8。\n第四次调用 fn 是在 105ms。fn(4) 返回 8。\n第五次调用 fn 是在 140ms。fn(4) 返回 8。\n第六次调用 fn 是在 175ms。fn(4) 返回 8。\n在 t=190ms 时取消\n</pre>\n\n<p><strong class=\"example\">示例 2:</strong></p>\n\n<pre>\n<b>输入:</b>fn = (x1, x2) => (x1 * x2), args = [2, 5], t = 30, cancelT = 165\n<strong>输出:</strong> \n[\n {\"time\": 0, \"returned\": 10},\n {\"time\": 30, \"returned\": 10},\n {\"time\": 60, \"returned\": 10},\n {\"time\": 90, \"returned\": 10},\n {\"time\": 120, \"returned\": 10},\n {\"time\": 150, \"returned\": 10}\n]\n<strong>解释:</strong>\nconst cancelTimeMs = 165; \nconst cancelFn = cancellable((x1, x2) => (x1 * x2), [2, 5], 30) \nsetTimeout(cancelFn, cancelTimeMs)\n\n每隔 30ms,调用 fn(2, 5)。直到 t=165ms,然后取消。\n第一次调用 fn 是在 0ms\n第二次调用 fn 是在 30ms\n第三次调用 fn 是在 60ms\n第四次调用 fn 是在 90ms\n第五次调用 fn 是在 120ms\n第六次调用 fn 是在 150ms\n在 165ms 取消\n</pre>\n\n<p><strong class=\"example\">示例 3:</strong></p>\n\n<pre>\n<b>输入:</b>fn = (x1, x2, x3) => (x1 + x2 + x3), args = [5, 1, 3], t = 50, cancelT = 180\n<b>输出:</b>\n[\n {\"time\": 0, \"returned\": 9},\n {\"time\": 50, \"returned\": 9},\n {\"time\": 100, \"returned\": 9},\n {\"time\": 150, \"returned\": 9}\n]\n<b>解释:</b>\nconst cancelTimeMs = 180;\nconst cancelFn = cancellable((x1, x2, x3) => (x1 + x2 + x3), [5, 1, 3], 50)\nsetTimeout(cancelFn, cancelTimeMs)\n\n每隔 50ms,调用 fn(5, 1, 3)。直到 t=180ms,然后取消。\n第一次调用 fn 是在 0ms\n第二次调用 fn 是在 50ms\n第三次调用 fn 是在 100ms\n第四次调用 fn 是在 150ms\n在 180ms 取消\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>fn</code> 是一个函数</li>\n\t<li><code>args</code> 是一个有效的 JSON 数组</li>\n\t<li><code>1 <= args.length <= 10</code></li>\n\t<li><code><font face=\"monospace\">30 <= t <= 100</font></code></li>\n\t<li><code><font face=\"monospace\">10 <= cancelT <= 500</font></code></li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Easy",
|
||||
"likes": 3,
|
||||
"likes": 5,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
"contributors": [],
|
||||
"langToValidPlayground": "{\"cpp\": true, \"java\": true, \"python\": true, \"python3\": true, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"typescript\": false, \"bash\": false, \"php\": false, \"swift\": false, \"kotlin\": false, \"dart\": false, \"golang\": false, \"ruby\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"rust\": false, \"racket\": false, \"erlang\": false, \"elixir\": false, \"pythondata\": false, \"react\": false, \"vanillajs\": false, \"postgresql\": false, \"cangjie\": false}",
|
||||
"langToValidPlayground": "{\"cpp\": true, \"java\": true, \"python3\": true, \"python\": true, \"javascript\": false, \"typescript\": false, \"csharp\": false, \"c\": false, \"golang\": false, \"kotlin\": false, \"swift\": false, \"rust\": false, \"ruby\": false, \"php\": false, \"dart\": false, \"scala\": false, \"elixir\": false, \"erlang\": false, \"racket\": false, \"cangjie\": false, \"bash\": false, \"html\": false, \"pythonml\": false, \"react\": false, \"vanillajs\": false, \"mysql\": false, \"mssql\": false, \"postgresql\": false, \"oraclesql\": false, \"pythondata\": false}",
|
||||
"topicTags": [],
|
||||
"companyTagStats": null,
|
||||
"codeSnippets": [
|
||||
@@ -34,7 +34,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"4.5K\", \"totalSubmission\": \"6.1K\", \"totalAcceptedRaw\": 4513, \"totalSubmissionRaw\": 6148, \"acRate\": \"73.4%\"}",
|
||||
"stats": "{\"totalAccepted\": \"5.6K\", \"totalSubmission\": \"7.5K\", \"totalAcceptedRaw\": 5562, \"totalSubmissionRaw\": 7504, \"acRate\": \"74.1%\"}",
|
||||
"hints": [],
|
||||
"solution": null,
|
||||
"status": null,
|
||||
@@ -44,7 +44,7 @@
|
||||
"judgeType": "large",
|
||||
"mysqlSchemas": [],
|
||||
"enableRunCode": true,
|
||||
"envInfo": "{\"javascript\":[\"JavaScript\",\"<p>\\u7248\\u672c\\uff1a<code>Node.js 20.10.0<\\/code><\\/p>\\r\\n\\r\\n<p>\\u60a8\\u7684\\u4ee3\\u7801\\u5728\\u6267\\u884c\\u65f6\\u5c06\\u5e26\\u4e0a <code>--harmony<\\/code> \\u6807\\u8bb0\\u6765\\u5f00\\u542f <a href=\\\"http:\\/\\/node.green\\/\\\" target=\\\"_blank\\\">\\u65b0\\u7248ES6\\u7279\\u6027<\\/a>\\u3002<\\/p>\\r\\n\\r\\n<p><a href=\\\"https:\\/\\/lodash.com\\\" target=\\\"_blank\\\">lodash.js<\\/a> \\u5e93\\u5df2\\u7ecf\\u9ed8\\u8ba4\\u88ab\\u5305\\u542b\\u3002<\\/p>\\r\\n\\r\\n<p> \\u5982\\u9700\\u4f7f\\u7528\\u961f\\u5217\\/\\u4f18\\u5148\\u961f\\u5217\\uff0c\\u60a8\\u53ef\\u4f7f\\u7528 <a href=\\\"https:\\/\\/github.com\\/datastructures-js\\/priority-queue\\/blob\\/v5\\/README.md\\\" target=\\\"_blank\\\"> datastructures-js\\/priority-queue@5.4.0<\\/a>\\uff0c<a href=\\\"https:\\/\\/github.com\\/datastructures-js\\/queue\\/tree\\/v4.2.3\\\" target=\\\"_blank\\\"> datastructures-js\\/queue@4.2.3<\\/a> \\u4ee5\\u53ca <a href=\\\"https:\\/\\/github.com\\/datastructures-js\\/deque\\/tree\\/v1.0.4\\\" target=\\\"_blank\\\"> datastructures-js\\/deque@1.0.4<\\/a>\\u3002<\\/p>\"],\"typescript\":[\"TypeScript\",\"<p>TypeScript 5.1.6<\\/p>\\r\\n\\r\\n<p>Compile Options: --alwaysStrict --strictBindCallApply --strictFunctionTypes --target ES2022<\\/p>\\r\\n\\r\\n<p><a href=\\\"https:\\/\\/lodash.com\\\" target=\\\"_blank\\\">lodash.js<\\/a> \\u5e93\\u5df2\\u7ecf\\u9ed8\\u8ba4\\u88ab\\u5305\\u542b\\u3002<\\/p>\\r\\n\\r\\n<p> \\u5982\\u9700\\u4f7f\\u7528\\u961f\\u5217\\/\\u4f18\\u5148\\u961f\\u5217\\uff0c\\u60a8\\u53ef\\u4f7f\\u7528 <a href=\\\"https:\\/\\/github.com\\/datastructures-js\\/priority-queue\\/blob\\/v5\\/README.md\\\" target=\\\"_blank\\\"> datastructures-js\\/priority-queue@5.4.0<\\/a>\\uff0c<a href=\\\"https:\\/\\/github.com\\/datastructures-js\\/queue\\/tree\\/v4.2.3\\\" target=\\\"_blank\\\"> datastructures-js\\/queue@4.2.3<\\/a> \\u4ee5\\u53ca <a href=\\\"https:\\/\\/github.com\\/datastructures-js\\/deque\\/tree\\/v1.0.4\\\" target=\\\"_blank\\\"> datastructures-js\\/deque@1.0.4<\\/a>\\u3002<\\/p>\"]}",
|
||||
"envInfo": "{\"javascript\":[\"JavaScript\",\"<p>\\u7248\\u672c\\uff1a<code>Node.js 22.14.0<\\/code><\\/p>\\r\\n\\r\\n<p>\\u60a8\\u7684\\u4ee3\\u7801\\u5728\\u6267\\u884c\\u65f6\\u5c06\\u5e26\\u4e0a <code>--harmony<\\/code> \\u6807\\u8bb0\\u6765\\u5f00\\u542f <a href=\\\"http:\\/\\/node.green\\/\\\" target=\\\"_blank\\\">\\u65b0\\u7248ES6\\u7279\\u6027<\\/a>\\u3002<\\/p>\\r\\n\\r\\n<p><a href=\\\"https:\\/\\/lodash.com\\\" target=\\\"_blank\\\">lodash.js<\\/a> \\u5e93\\u5df2\\u7ecf\\u9ed8\\u8ba4\\u88ab\\u5305\\u542b\\u3002<\\/p>\\r\\n\\r\\n<p> \\u60a8\\u53ef\\u4f7f\\u7528 <a href=\\\"https:\\/\\/datastructures-js.info\\/docs\\\" target=\\\"_blank\\\"> datastructures-js <\\/a>\\u5e93\\u6240\\u63d0\\u4f9b\\u7684\\u6570\\u636e\\u7ed3\\u6784\\u3002<\\/p>\"],\"typescript\":[\"TypeScript\",\"<p>TypeScript 5.7.3<\\/p>\\r\\n\\r\\n<p>Compile Options: --alwaysStrict --strictBindCallApply --strictFunctionTypes --target ES2024<\\/p>\\r\\n\\r\\n<p><a href=\\\"https:\\/\\/lodash.com\\\" target=\\\"_blank\\\">lodash.js<\\/a> \\u5e93\\u5df2\\u7ecf\\u9ed8\\u8ba4\\u88ab\\u5305\\u542b\\u3002<\\/p>\\r\\n\\r\\n<p> \\u60a8\\u53ef\\u4f7f\\u7528 <a href=\\\"https:\\/\\/datastructures-js.info\\/docs\\\" target=\\\"_blank\\\"> datastructures-js <\\/a>\\u5e93\\u6240\\u63d0\\u4f9b\\u7684\\u6570\\u636e\\u7ed3\\u6784\\u3002<\\/p>\"]}",
|
||||
"book": null,
|
||||
"isSubscribed": false,
|
||||
"isDailyQuestion": false,
|
||||
|
Reference in New Issue
Block a user