1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-03 14:32:54 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2023-06-12 23:05:37 +08:00
parent 96cb474414
commit 952a47471f
107 changed files with 22284 additions and 13277 deletions

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,58 @@
{
"data": {
"question": {
"questionId": "2874",
"questionFrontendId": "2720",
"categoryTitle": "Database",
"boundTopicId": 2299616,
"title": "Popularity Percentage",
"titleSlug": "popularity-percentage",
"content": null,
"translatedTitle": "受欢迎度百分比",
"translatedContent": null,
"isPaidOnly": true,
"difficulty": "Hard",
"likes": 0,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
"contributors": [],
"langToValidPlayground": null,
"topicTags": [],
"companyTagStats": null,
"codeSnippets": null,
"stats": "{\"totalAccepted\": \"26\", \"totalSubmission\": \"31\", \"totalAcceptedRaw\": 26, \"totalSubmissionRaw\": 31, \"acRate\": \"83.9%\"}",
"hints": [],
"solution": null,
"status": null,
"sampleTestCase": "{\"headers\":{\"Friends\":[\"user1\",\"user2\"]},\"rows\":{\"Friends\":[[2,1],[1,3],[4,1],[1,5],[1,6],[2,6],[7,2],[8,3],[3,9]]}}",
"metaData": "{\n \"mysql\": [\n \"Create table if not exists Friends (user1 int, user2 int)\"\n ],\n \"mssql\": [\n \"Create table Friends(user1 int, user2 int)\"\n ],\n \"oraclesql\": [\n \"Create table Friends(user1 int, user2 int)\"\n ],\n \"database\": true\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [
"Create table if not exists Friends (user1 int, user2 int)",
"Truncate table Friends",
"insert into Friends (user1, user2) values ('2', '1')",
"insert into Friends (user1, user2) values ('1', '3')",
"insert into Friends (user1, user2) values ('4', '1')",
"insert into Friends (user1, user2) values ('1', '5')",
"insert into Friends (user1, user2) values ('1', '6')",
"insert into Friends (user1, user2) values ('2', '6')",
"insert into Friends (user1, user2) values ('7', '2')",
"insert into Friends (user1, user2) values ('8', '3')",
"insert into Friends (user1, user2) values ('3', '9')"
],
"enableRunCode": true,
"envInfo": "{\"mysql\":[\"MySQL\",\"<p>\\u7248\\u672c\\uff1a<code>MySQL 8.0<\\/code><\\/p>\"],\"mssql\":[\"MS SQL Server\",\"<p>mssql server 2019.<\\/p>\"],\"oraclesql\":[\"Oracle\",\"<p>Oracle Sql 11.2.<\\/p>\"]}",
"book": null,
"isSubscribed": false,
"isDailyQuestion": false,
"dailyRecordStatus": null,
"editorType": "CKEDITOR",
"ugcQuestionId": null,
"style": "LEETCODE",
"exampleTestcases": "{\"headers\":{\"Friends\":[\"user1\",\"user2\"]},\"rows\":{\"Friends\":[[2,1],[1,3],[4,1],[1,5],[1,6],[2,6],[7,2],[8,3],[3,9]]}}",
"__typename": "QuestionNode"
}
}
}

View File

@@ -0,0 +1,59 @@
{
"data": {
"question": {
"questionId": "2859",
"questionFrontendId": "2723",
"categoryTitle": "JavaScript",
"boundTopicId": 2302687,
"title": "Add Two Promises",
"titleSlug": "add-two-promises",
"content": "Given two promises <code>promise1</code> and <code>promise2</code>, return a new promise. <code>promise1</code> and <code>promise2</code>&nbsp;will both resolve with a number. The returned promise should resolve with the sum of the two numbers.\n<p>&nbsp;</p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> \npromise1 = new Promise(resolve =&gt; setTimeout(() =&gt; resolve(2), 20)), \npromise2 = new Promise(resolve =&gt; setTimeout(() =&gt; resolve(5), 60))\n<strong>Output:</strong> 7\n<strong>Explanation:</strong> The two input promises resolve with the values of 2 and 5 respectively. The returned promise should resolve with a value of 2 + 5 = 7. The time the returned promise resolves is not judged for this problem.\n</pre>\n\n<p><strong class=\"example\">Example 2:</strong></p>\n\n<pre>\n<strong>Input:</strong> \npromise1 = new Promise(resolve =&gt; setTimeout(() =&gt; resolve(10), 50)), \npromise2 = new Promise(resolve =&gt; setTimeout(() =&gt; resolve(-12), 30))\n<strong>Output:</strong> -2\n<strong>Explanation:</strong> The two input promises resolve with the values of 10 and -12 respectively. The returned promise should resolve with a value of 10 + -12 = -2.\n</pre>\n\n<p>&nbsp;</p>\n<p><strong>Constraints:</strong></p>\n\n<ul>\n\t<li><code>promise1 and promise2 are&nbsp;promises that resolve&nbsp;with a number</code></li>\n</ul>\n",
"translatedTitle": "添加两个 Promise 对象",
"translatedContent": "给定两个 promise 对象&nbsp;<code>promise1</code> 和 <code>promise2</code>,返回一个新的 promise。<code>promise1</code> 和 <code>promise2</code> 都会被解析为一个数字。返回的 Promise 应该解析为这两个数字的和。\n<p>&nbsp;</p>\n\n<p><strong class=\"example\">示例 1</strong></p>\n\n<pre>\n<b>输入:</b>\npromise1 = new Promise(resolve =&gt; setTimeout(() =&gt; resolve(2), 20)), \npromise2 = new Promise(resolve =&gt; setTimeout(() =&gt; resolve(5), 60))\n<b>输出:</b>7\n<b>解释:</b>两个输入的 Promise 分别解析为值 2 和 5。返回的 Promise 应该解析为 2 + 5 = 7。返回的 Promise 解析的时间不作为判断条件。\n</pre>\n\n<p><strong class=\"example\">示例 2</strong></p>\n\n<pre>\n<b>输入:</b>\npromise1 = new Promise(resolve =&gt; setTimeout(() =&gt; resolve(10), 50)), \npromise2 = new Promise(resolve =&gt; setTimeout(() =&gt; resolve(-12), 30))\n<b>输出:</b>-2\n<b>解释:</b>两个输入的 Promise 分别解析为值 10 和 -12。返回的 Promise 应该解析为 10 + -12 = -2。\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>promise1 和 promise2 都是被解析为一个数字的 promise 对象</code></li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 0,
"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, \"ruby\": false, \"bash\": false, \"swift\": false, \"golang\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"kotlin\": false, \"rust\": false, \"php\": false, \"typescript\": false, \"racket\": false, \"erlang\": false, \"elixir\": false, \"dart\": false}",
"topicTags": [],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "JavaScript",
"langSlug": "javascript",
"code": "/**\n * @param {Promise} promise1\n * @param {Promise} promise2\n * @return {Promise}\n */\nvar addTwoPromises = async function(promise1, promise2) {\n \n};\n\n/**\n * addTwoPromises(Promise.resolve(2), Promise.resolve(2))\n * .then(console.log); // 4\n */",
"__typename": "CodeSnippetNode"
},
{
"lang": "TypeScript",
"langSlug": "typescript",
"code": "async function addTwoPromises(promise1: Promise<number>, promise2: Promise<number>): Promise<number> {\n\n};\n\n/**\n * addTwoPromises(Promise.resolve(2), Promise.resolve(2))\n * .then(console.log); // 4\n */",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"161\", \"totalSubmission\": \"177\", \"totalAcceptedRaw\": 161, \"totalSubmissionRaw\": 177, \"acRate\": \"91.0%\"}",
"hints": [],
"solution": null,
"status": null,
"sampleTestCase": "new Promise(resolve => setTimeout(() => resolve(2), 20))\nnew Promise(resolve => setTimeout(() => resolve(5), 60))",
"metaData": "{\n \"name\": \"addTwoPromises\",\n \"params\": [\n {\n \"name\": \"promise1\",\n \"type\": \"string\"\n },\n {\n \"type\": \"string\",\n \"name\": \"promise2\"\n }\n ],\n \"return\": {\n \"type\": \"integer\"\n },\n \"languages\": [\n \"javascript\",\n \"typescript\"\n ],\n \"manual\": true\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [],
"enableRunCode": true,
"envInfo": "{\"javascript\":[\"JavaScript\",\"<p>\\u7248\\u672c\\uff1a<code>Node.js 16.13.2<\\/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\\/tree\\/fb4fdb984834421279aeb081df7af624d17c2a03\\\" target=\\\"_blank\\\"> datastructures-js\\/priority-queue@5.3.0<\\/a> \\u548c <a href=\\\"https:\\/\\/github.com\\/datastructures-js\\/queue\\/tree\\/e63563025a5a805aa16928cb53bcd517bfea9230\\\" target=\\\"_blank\\\"> datastructures-js\\/queue@4.2.1<\\/a>\\u3002<\\/p>\"],\"typescript\":[\"TypeScript\",\"<p>TypeScript 4.5.4<\\/p>\\r\\n\\r\\n<p>Compile Options: --alwaysStrict --strictBindCallApply --strictFunctionTypes --target ES2020<\\/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\\/tree\\/fb4fdb984834421279aeb081df7af624d17c2a03\\\" target=\\\"_blank\\\"> datastructures-js\\/priority-queue@5.3.0<\\/a> \\u548c <a href=\\\"https:\\/\\/github.com\\/datastructures-js\\/queue\\/tree\\/e63563025a5a805aa16928cb53bcd517bfea9230\\\" target=\\\"_blank\\\"> datastructures-js\\/queue@4.2.1<\\/a>\\u3002<\\/p>\"]}",
"book": null,
"isSubscribed": false,
"isDailyQuestion": false,
"dailyRecordStatus": null,
"editorType": "CKEDITOR",
"ugcQuestionId": null,
"style": "LEETCODE",
"exampleTestcases": "new Promise(resolve => setTimeout(() => resolve(2), 20))\nnew Promise(resolve => setTimeout(() => resolve(5), 60))\nnew Promise(resolve => setTimeout(() => resolve(10), 50))\nnew Promise(resolve => setTimeout(() => resolve(-12), 30))",
"__typename": "QuestionNode"
}
}
}

View File

@@ -0,0 +1,59 @@
{
"data": {
"question": {
"questionId": "2863",
"questionFrontendId": "2726",
"categoryTitle": "JavaScript",
"boundTopicId": 2300583,
"title": "Calculator with Method Chaining",
"titleSlug": "calculator-with-method-chaining",
"content": "<p>Design a <code>Calculator</code> class. The class should provide the&nbsp;mathematical operations of&nbsp;addition, subtraction, multiplication, division, and exponentiation. It should also allow consecutive operations to be performed using method chaining.&nbsp;The <code>Calculator</code> class constructor should accept a number&nbsp;which serves as the&nbsp;initial value of <code>result</code>.</p>\n\n<p>Your <font face=\"monospace\"><code>Calculator</code>&nbsp;</font>class should have the following methods:</p>\n\n<ul>\n\t<li><code>add</code> - This method adds the given number <code>value</code> to the&nbsp;<code>result</code> and returns the updated <code>Calculator</code>.</li>\n\t<li><code>subtract</code> -&nbsp;This method subtracts the given number <code>value</code>&nbsp;from the&nbsp;<code>result</code> and returns the updated <code>Calculator</code>.</li>\n\t<li><code>multiply</code> -&nbsp;This method multiplies the <code>result</code>&nbsp; by the given number <code>value</code> and returns the updated <code>Calculator</code>.</li>\n\t<li><code>divide</code> -&nbsp;This method divides the <code>result</code> by the given number <code>value</code> and returns the updated <code>Calculator</code>. If the passed value is <code>0</code>, an error <code>&quot;Division by zero is not allowed&quot;</code> should be thrown.</li>\n\t<li><code>power</code> -&nbsp;This method raises the&nbsp;<code>result</code> to the power of the given number <code>value</code> and returns the updated <code>Calculator</code>.</li>\n\t<li><code>getResult</code> -&nbsp;This method returns the <code>result</code>.</li>\n</ul>\n\n<p>Solutions within&nbsp;<code>10<sup>-5</sup></code>&nbsp;of the actual result are considered correct.</p>\n\n<p>&nbsp;</p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> actions = [&quot;Calculator&quot;, &quot;add&quot;, &quot;subtract&quot;, &quot;getResult&quot;], values = [10, 5, 7]\n<strong>Output:</strong> 8\n<strong>Explanation:</strong> \nnew Calculator(10).add(5).subtract(7).getResult() // 10 + 5 - 7 = 8\n</pre>\n\n<p><strong class=\"example\">Example 2:</strong></p>\n\n<pre>\n<strong>Input:</strong> actions = [&quot;Calculator&quot;, &quot;multiply&quot;, &quot;power&quot;, &quot;getResult&quot;], values = [2, 5, 2]\n<strong>Output:</strong> 100\n<strong>Explanation:</strong> \nnew Calculator(2).multiply(5).power(2).getResult() // (2 * 5) ^ 2 = 100\n</pre>\n\n<p><strong class=\"example\">Example 3:</strong></p>\n\n<pre>\n<strong>Input:</strong> actions = [&quot;Calculator&quot;, &quot;divide&quot;, &quot;getResult&quot;], values = [20, 0]\n<strong>Output:</strong> &quot;Division by zero is not allowed&quot;\n<strong>Explanation:</strong> \nnew Calculator(20).divide(0).getResult() // 20 / 0 \n\nThe error should be thrown because we cannot divide by zero.\n</pre>\n\n<p>&nbsp;</p>\n<p><strong>Constraints:</strong></p>\n\n<ul>\n\t<li><code>2 &lt;= actions.length &lt;= 2 * 10<sup>4</sup></code></li>\n\t<li><code>1 &lt;= values.length &lt;= 2 * 10<sup>4</sup></code><code>&nbsp;- 1</code></li>\n\t<li><code>actions[i] is one of &quot;Calculator&quot;, &quot;add&quot;, &quot;subtract&quot;, &quot;multiply&quot;, &quot;divide&quot;, &quot;power&quot;, and&nbsp;&quot;getResult&quot;</code></li>\n\t<li><code><font face=\"monospace\">Last action is always &quot;getResult&quot;</font></code></li>\n\t<li><code><font face=\"monospace\">values is a JSON array of numbers</font></code></li>\n</ul>\n",
"translatedTitle": "使用方法链的计算器",
"translatedContent": "<p>设计一个类 <code>Calculator</code> 。该类应提供加法、减法、乘法、除法和乘方等数学运算功能。同时,它还应支持连续操作的方法链式调用。<code>Calculator</code> 类的构造函数应接受一个数字作为 <code>result</code> 的初始值。</p>\n\n<p>你的 <code>Calculator</code> 类应包含以下方法:</p>\n\n<ul>\n\t<li><code>add</code> - 将给定的数字 <code>value</code> 与 <code>result</code> 相加,并返回更新后的 <code>Calculator</code> 对象。</li>\n\t<li><code>subtract</code> - 从 <code>result</code> 中减去给定的数字 <code>value</code>&nbsp;,并返回更新后的 <code>Calculator</code> 对象。</li>\n\t<li><code>multiply</code> - 将 <code>result</code> 乘以给定的数字 <code>value</code> ,并返回更新后的&nbsp;<code>Calculator</code> 对象。</li>\n\t<li><code>divide</code> - 将 <code>result</code> 除以给定的数字 <code>value</code> ,并返回更新后的&nbsp;<code>Calculator</code> 对象。如果传入的值为 <code>0</code> ,则抛出错误 <code>\"Division by zero is not allowed\"</code> 。</li>\n\t<li><code>power</code> - 将 <code>result</code> 的值乘以给定的数字 <code>value</code> ,并返回更新后的&nbsp;<code>Calculator</code> 对象。</li>\n\t<li><code>getResult</code> - 返回 <code>result</code> 的值。</li>\n</ul>\n\n<p>结果与实际结果相差在 <code>10<sup>-5</sup></code><sup>&nbsp;</sup>范围内的解被认为是正确的。</p>\n\n<p>&nbsp;</p>\n\n<p><b>示例 1</b></p>\n\n<pre>\n<b>输入:</b>actions = [\"Calculator\", \"add\", \"subtract\", \"getResult\"], values = [10, 5, 7]\n<b>输出:</b>8\n<b>解释:</b>\nnew Calculator(10).add(5).subtract(7).getResult() // 10 + 5 - 7 = 8\n</pre>\n\n<p><strong class=\"example\">示例 2</strong></p>\n\n<pre>\n<b>输入:</b>actions = [\"Calculator\", \"multiply\", \"power\", \"getResult\"], values = [2, 5, 2]\n<b>输出:</b>100\n<b>解释:</b>\nnew Calculator(2).multiply(5).power(2).getResult() // (2 * 5) ^ 2 = 100\n</pre>\n\n<p><strong class=\"example\">示例 3</strong></p>\n\n<pre>\n<b>输入:</b>actions = [\"Calculator\", \"divide\", \"getResult\"], values = [20, 0]\n<b>输出:</b>\"Division by zero is not allowed\"\n<b>解释:</b>\nnew Calculator(20).divide(0).getResult() // 20 / 0 \n\n由于不能除以零因此应抛出错误。\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>2 &lt;= actions.length &lt;= 2 * 10<sup>4</sup></code></li>\n\t<li><code>1 &lt;= values.length &lt;= 2 * 10<sup>4</sup></code><code>&nbsp;- 1</code></li>\n\t<li><code>actions[i] 是 \"Calculator\", \"add\", \"subtract\", \"multiply\", \"divide\", \"power\", 和 \"getResult\" 其中的元素</code></li>\n\t<li><code><font face=\"monospace\">最后一个操作总是&nbsp;\"getResult\"</font></code></li>\n\t<li><code><font face=\"monospace\">values </font>是一个数字的 JSON 数组</code></li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 0,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
"contributors": [],
"langToValidPlayground": "{\"cpp\": false, \"java\": false, \"python\": true, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"ruby\": false, \"bash\": false, \"swift\": false, \"golang\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"kotlin\": false, \"rust\": false, \"php\": false, \"typescript\": false, \"racket\": false, \"erlang\": false, \"elixir\": false, \"dart\": false}",
"topicTags": [],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "JavaScript",
"langSlug": "javascript",
"code": "class Calculator {\n \n /** \n * @param {number} value\n */\n constructor(value) {\n\n }\n\n /** \n * @param {number} value\n * @return {Calculator}\n */\n add(value){\n\n }\n\n /** \n * @param {number} value\n * @return {Calculator}\n */\n subtract(value){\n\n }\n\n /** \n * @param {number} value\n * @return {Calculator}\n */ \n multiply(value) {\n\n }\n\n /** \n * @param {number} value\n * @return {Calculator}\n */\n divide(value) {\n\n }\n \n /** \n * @param {number} value\n * @return {Calculator}\n */\n power(value) {\n\n }\n \n /** \n * @return {number}\n */\n getResult() {\n \n }\n}",
"__typename": "CodeSnippetNode"
},
{
"lang": "TypeScript",
"langSlug": "typescript",
"code": "class Calculator {\n \n constructor(value : number) {\n\n }\n \n add(value : number) : Calculator {\n\n }\n \n subtract(value : number) : Calculator {\n\n }\n \n multiply(value : number) : Calculator {\n\n }\n\n divide(value : number) : Calculator {\n\n }\n \n power(value : number) : Calculator {\n\n }\n\n getResult() : number {\n \n }\n}",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"124\", \"totalSubmission\": \"192\", \"totalAcceptedRaw\": 124, \"totalSubmissionRaw\": 192, \"acRate\": \"64.6%\"}",
"hints": [],
"solution": null,
"status": null,
"sampleTestCase": "[\"Calculator\", \"add\", \"subtract\", \"getResult\"]\n[10, 5, 7]",
"metaData": "{\n \"name\": \"foobar\",\n \"params\": [\n {\n \"name\": \"actions\",\n \"type\": \"string[]\"\n },\n {\n \"type\": \"double[]\",\n \"name\": \"values\"\n }\n ],\n \"return\": {\n \"type\": \"integer\"\n },\n \"languages\": [\n \"typescript\",\n \"javascript\"\n ],\n \"manual\": true\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [],
"enableRunCode": true,
"envInfo": "{\"javascript\":[\"JavaScript\",\"<p>\\u7248\\u672c\\uff1a<code>Node.js 16.13.2<\\/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\\/tree\\/fb4fdb984834421279aeb081df7af624d17c2a03\\\" target=\\\"_blank\\\"> datastructures-js\\/priority-queue@5.3.0<\\/a> \\u548c <a href=\\\"https:\\/\\/github.com\\/datastructures-js\\/queue\\/tree\\/e63563025a5a805aa16928cb53bcd517bfea9230\\\" target=\\\"_blank\\\"> datastructures-js\\/queue@4.2.1<\\/a>\\u3002<\\/p>\"],\"typescript\":[\"TypeScript\",\"<p>TypeScript 4.5.4<\\/p>\\r\\n\\r\\n<p>Compile Options: --alwaysStrict --strictBindCallApply --strictFunctionTypes --target ES2020<\\/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\\/tree\\/fb4fdb984834421279aeb081df7af624d17c2a03\\\" target=\\\"_blank\\\"> datastructures-js\\/priority-queue@5.3.0<\\/a> \\u548c <a href=\\\"https:\\/\\/github.com\\/datastructures-js\\/queue\\/tree\\/e63563025a5a805aa16928cb53bcd517bfea9230\\\" target=\\\"_blank\\\"> datastructures-js\\/queue@4.2.1<\\/a>\\u3002<\\/p>\"]}",
"book": null,
"isSubscribed": false,
"isDailyQuestion": false,
"dailyRecordStatus": null,
"editorType": "CKEDITOR",
"ugcQuestionId": null,
"style": "LEETCODE",
"exampleTestcases": "[\"Calculator\", \"add\", \"subtract\", \"getResult\"]\n[10, 5, 7]\n[\"Calculator\", \"multiply\", \"power\", \"getResult\"]\n[2, 5, 2]\n[\"Calculator\", \"divide\", \"getResult\"]\n[20, 0]",
"__typename": "QuestionNode"
}
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,59 @@
{
"data": {
"question": {
"questionId": "2807",
"questionFrontendId": "2721",
"categoryTitle": "JavaScript",
"boundTopicId": 2302685,
"title": "Execute Asynchronous Functions in Parallel",
"titleSlug": "execute-asynchronous-functions-in-parallel",
"content": "<p>Given an array of asynchronous&nbsp;functions&nbsp;<code>functions</code>, return a new promise <code>promise</code>. Each function in the array accepts no arguments&nbsp;and returns a promise.</p>\n\n<p><code>promise</code> resolves:</p>\n\n<ul>\n\t<li>When all the promises returned from&nbsp;<code>functions</code>&nbsp;were resolved successfully.&nbsp;The resolved&nbsp;value of&nbsp;<code>promise</code> should be an array of all the resolved values of promises in the same order as they were in the&nbsp;<code>functions.</code></li>\n</ul>\n\n<p><code>promise</code> rejects:</p>\n\n<ul>\n\t<li>When any&nbsp;of the promises&nbsp;returned from&nbsp;<code>functions</code>&nbsp;were rejected.&nbsp;<code>promise</code> should also&nbsp;reject&nbsp;with the reason of the first rejection.</li>\n</ul>\n\n<p>Please solve it without using the built-in&nbsp;<code>Promise.all</code>&nbsp;function.</p>\n\n<p>&nbsp;</p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> functions = [\n&nbsp; () =&gt; new Promise(resolve =&gt; setTimeout(() =&gt; resolve(5), 200))\n]\n<strong>Output:</strong> {&quot;t&quot;: 200, &quot;resolved&quot;: [5]}\n<strong>Explanation:</strong> \npromiseAll(functions).then(console.log); // [5]\n\nThe single function was resolved at 200ms with a value of 5.\n</pre>\n\n<p><strong class=\"example\">Example 2:</strong></p>\n\n<pre>\n<strong>Input:</strong> functions = [\n () =&gt; new Promise(resolve =&gt; setTimeout(() =&gt; resolve(1), 200)), \n () =&gt; new Promise((resolve, reject) =&gt; setTimeout(() =&gt; reject(&quot;Error&quot;), 100))\n]\n<strong>Output:</strong> {&quot;t&quot;: 100, &quot;rejected&quot;: &quot;Error&quot;}\n<strong>Explanation:</strong> Since one of the promises rejected, the returned promise also rejected with the same error at the same time.\n</pre>\n\n<p><strong class=\"example\">Example 3:</strong></p>\n\n<pre>\n<strong>Input:</strong> functions = [\n () =&gt; new Promise(resolve =&gt; setTimeout(() =&gt; resolve(4), 50)), \n () =&gt; new Promise(resolve =&gt; setTimeout(() =&gt; resolve(10), 150)), \n () =&gt; new Promise(resolve =&gt; setTimeout(() =&gt; resolve(16), 100))\n]\n<strong>Output:</strong> {&quot;t&quot;: 150, &quot;resolved&quot;: [4, 10, 16]}\n<strong>Explanation:</strong> All the promises resolved with a value. The returned promise resolved when the last promise resolved.\n</pre>\n\n<p>&nbsp;</p>\n<p><strong>Constraints:</strong></p>\n\n<ul>\n\t<li><code>functions&nbsp;is an array of functions that returns promises</code></li>\n\t<li><code>1 &lt;= functions.length &lt;= 10</code></li>\n</ul>\n",
"translatedTitle": "并行执行异步函数",
"translatedContent": "<p>给定一个异步函数数组 <code>functions</code>,返回一个新的 promise 对象&nbsp;<code>promise</code>。数组中的每个函数都不接受参数并返回一个 promise。</p>\n\n<p><code>promise</code> resolve 条件:</p>\n\n<ul>\n\t<li>当所有从 <code>functions</code> 返回的 promise 都成功解析时。<code>promise</code> 的解析值应该是一个按照它们在 <code>functions</code> 中的顺序排列的 promise 的解析值数组。</li>\n</ul>\n\n<p><code>promise</code>&nbsp;reject 条件:</p>\n\n<ul>\n\t<li>当任何从 <code>functions</code> 返回的 promise 被拒绝时。<code>promise</code> 也会被拒绝,并返回第一个拒绝的原因。</li>\n</ul>\n\n<p>请在不使用内置的 <code>Promise.all</code> 函数的情况下解决。</p>\n\n<p>&nbsp;</p>\n\n<p><strong class=\"example\">示例 1</strong></p>\n\n<pre>\n<b>输入:</b>functions = [\n&nbsp; () =&gt; new Promise(resolve =&gt; setTimeout(() =&gt; resolve(5), 200))\n]\n<b>输出:</b>{\"t\": 200, \"resolved\": [5]}\n<b>解释:</b>\npromiseAll(functions).then(console.log); // [5]\n\n单个函数在 200 毫秒后以值 5 成功解析。\n</pre>\n\n<p><strong class=\"example\">示例 2</strong></p>\n\n<pre>\n<b>输入:</b>functions = [\n () =&gt; new Promise(resolve =&gt; setTimeout(() =&gt; resolve(1), 200)), \n () =&gt; new Promise((resolve, reject) =&gt; setTimeout(() =&gt; reject(\"Error\"), 100))\n]\n<b>输出:</b>{\"t\": 100, \"rejected\": \"Error\"}\n<b>解释:</b>由于其中一个 promise 被拒绝,返回的 promise 也在同一时间被拒绝并返回相同的错误。\n</pre>\n\n<p><strong class=\"example\">示例 3</strong></p>\n\n<pre>\n<b>输入:</b>functions = [\n () =&gt; new Promise(resolve =&gt; setTimeout(() =&gt; resolve(4), 50)), \n () =&gt; new Promise(resolve =&gt; setTimeout(() =&gt; resolve(10), 150)), \n () =&gt; new Promise(resolve =&gt; setTimeout(() =&gt; resolve(16), 100))\n]\n<b>输出:</b>{\"t\": 150, \"resolved\": [4, 10, 16]}\n<b>解释:</b>所有的 promise 都成功执行。当最后一个 promise 被解析时,返回的 promise 也被解析了。\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>functions&nbsp;is an array of functions that returns promises</code></li>\n\t<li><code>1 &lt;= functions.length &lt;= 10</code></li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Medium",
"likes": 0,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
"contributors": [],
"langToValidPlayground": "{\"cpp\": false, \"java\": true, \"python\": true, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"ruby\": false, \"bash\": false, \"swift\": false, \"golang\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"kotlin\": false, \"rust\": false, \"php\": false, \"typescript\": false, \"racket\": false, \"erlang\": false, \"elixir\": false, \"dart\": false}",
"topicTags": [],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "JavaScript",
"langSlug": "javascript",
"code": "/**\n * @param {Array<Function>} functions\n * @return {Promise<any>}\n */\nvar promiseAll = async function(functions) {\n \n};\n\n/**\n * const promise = promiseAll([() => new Promise(res => res(42))])\n * promise.then(console.log); // [42]\n */",
"__typename": "CodeSnippetNode"
},
{
"lang": "TypeScript",
"langSlug": "typescript",
"code": "async function promiseAll<T>(functions: (() => Promise<T>)[]): Promise<T[]> {\n\n};\n\n/**\n * const promise = promiseAll([() => new Promise(res => res(42))])\n * promise.then(console.log); // [42]\n */",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"75\", \"totalSubmission\": \"102\", \"totalAcceptedRaw\": 75, \"totalSubmissionRaw\": 102, \"acRate\": \"73.5%\"}",
"hints": [],
"solution": null,
"status": null,
"sampleTestCase": "[() => new Promise(resolve => setTimeout(() => resolve(5), 200))]",
"metaData": "{\n \"name\": \"promiseAll\",\n \"params\": [\n {\n \"name\": \"functions\",\n \"type\": \"string[]\"\n }\n ],\n \"return\": {\n \"type\": \"integer\"\n },\n \"languages\": [\n \"javascript\",\n \"typescript\"\n ],\n \"manual\": true\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [],
"enableRunCode": true,
"envInfo": "{\"javascript\":[\"JavaScript\",\"<p>\\u7248\\u672c\\uff1a<code>Node.js 16.13.2<\\/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\\/tree\\/fb4fdb984834421279aeb081df7af624d17c2a03\\\" target=\\\"_blank\\\"> datastructures-js\\/priority-queue@5.3.0<\\/a> \\u548c <a href=\\\"https:\\/\\/github.com\\/datastructures-js\\/queue\\/tree\\/e63563025a5a805aa16928cb53bcd517bfea9230\\\" target=\\\"_blank\\\"> datastructures-js\\/queue@4.2.1<\\/a>\\u3002<\\/p>\"],\"typescript\":[\"TypeScript\",\"<p>TypeScript 4.5.4<\\/p>\\r\\n\\r\\n<p>Compile Options: --alwaysStrict --strictBindCallApply --strictFunctionTypes --target ES2020<\\/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\\/tree\\/fb4fdb984834421279aeb081df7af624d17c2a03\\\" target=\\\"_blank\\\"> datastructures-js\\/priority-queue@5.3.0<\\/a> \\u548c <a href=\\\"https:\\/\\/github.com\\/datastructures-js\\/queue\\/tree\\/e63563025a5a805aa16928cb53bcd517bfea9230\\\" target=\\\"_blank\\\"> datastructures-js\\/queue@4.2.1<\\/a>\\u3002<\\/p>\"]}",
"book": null,
"isSubscribed": false,
"isDailyQuestion": false,
"dailyRecordStatus": null,
"editorType": "CKEDITOR",
"ugcQuestionId": null,
"style": "LEETCODE",
"exampleTestcases": "[() => new Promise(resolve => setTimeout(() => resolve(5), 200))]\n[() => new Promise(resolve => setTimeout(() => resolve(1), 200)), () => new Promise((resolve, reject) => setTimeout(() => reject(\"Error\"), 100))]\n[() => new Promise(resolve => setTimeout(() => resolve(4), 50)), () => new Promise(resolve => setTimeout(() => resolve(10), 150)), () => new Promise(resolve => setTimeout(() => resolve(16), 100))]",
"__typename": "QuestionNode"
}
}
}

View File

@@ -0,0 +1,59 @@
{
"data": {
"question": {
"questionId": "2821",
"questionFrontendId": "2715",
"categoryTitle": "JavaScript",
"boundTopicId": 2293968,
"title": "Execute Cancellable Function With Delay",
"titleSlug": "execute-cancellable-function-with-delay",
"content": "<p>Given a function <code>fn</code>, an array or arguments&nbsp;<code>args</code>, and a timeout&nbsp;<code>t</code>&nbsp;in milliseconds, return a cancel function <code>cancelFn</code>.</p>\n\n<p>After a delay of&nbsp;<code>t</code>,&nbsp;<code>fn</code>&nbsp;should be called with <code>args</code> passed as parameters <strong>unless</strong> <code>cancelFn</code> was called first. In that case,&nbsp;<code>fn</code> should never be called.</p>\n\n<p>&nbsp;</p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> fn = (x) =&gt; x * 5, args = [2], t = 20, cancelTime = 50\n<strong>Output:</strong> [{&quot;time&quot;: 20, &quot;returned&quot;: 10}]\n<strong>Explanation:</strong> \nconst cancel = cancellable(fn, [2], 20); // fn(2) called at t=20ms\nsetTimeout(cancel, 50);\n\nthe cancelTime (50ms) is after the delay time (20ms), so fn(2) should be called at t=20ms. The value returned from fn is 10.\n</pre>\n\n<p><strong class=\"example\">Example 2:</strong></p>\n\n<pre>\n<strong>Input:</strong> fn = (x) =&gt; x**2, args = [2], t = 100, cancelTime = 50\n<strong>Output:</strong> []\n<strong>Explanation:</strong> fn(2) was never called because cancelTime (50ms) is before the delay time (100ms).\n</pre>\n\n<p><strong class=\"example\">Example 3:</strong></p>\n\n<pre>\n<strong>Input:</strong> fn = (x1, x2) =&gt; x1 * x2, args = [2,4], t = 30, cancelTime = 100\n<strong>Output:</strong> [{&quot;time&quot;: 30, &quot;returned&quot;: 8}]\n<strong>Explanation:</strong> fn(2, 4) was called at t=30ms because cancelTime &gt; t.\n</pre>\n\n<p>&nbsp;</p>\n<p><strong>Constraints:</strong></p>\n\n<ul>\n\t<li><code>fn is a function</code></li>\n\t<li><code>args is a valid JSON array</code></li>\n\t<li><code>1 &lt;= args.length &lt;= 10</code></li>\n\t<li><code><font face=\"monospace\">20 &lt;= t &lt;= 1000</font></code></li>\n\t<li><code><font face=\"monospace\">10 &lt;= cancelT &lt;= 1000</font></code></li>\n</ul>\n",
"translatedTitle": "执行可取消的延迟函数",
"translatedContent": "<p>现给定一个函数 <code>fn</code>&nbsp;,一个参数数组 <code>args</code> 和一个以毫秒为单位的超时时间 <code>t</code> ,返回一个取消函数 <code>cancelFn</code> 。</p>\n\n<p>在经过 <code>t</code> 毫秒的延迟后,<strong>除非</strong> 先调用 <code>cancelFn</code> ,否则&nbsp;<code>fn</code> 应该以 <code>args</code> 作为参数被调用。并且在这种情况下,<code>fn</code> 不应该被调用。</p>\n\n<p>&nbsp;</p>\n\n<p><strong class=\"example\">示例 1:</strong></p>\n\n<pre>\n<b>输入:</b>fn = (x) =&gt; x * 5, args = [2], t = 20, cancelTime = 50\n<b>输出:</b>[{\"time\": 20, \"returned\": 10}]\n<b>解释:</b>\nconst cancel = cancellable(fn, [2], 20); // // 在 t=20ms 时调用 fn(2)\nsetTimeout(cancel, 50);\n\ncancelTime50ms在延迟时间20ms之后所以 fn(2) 应该在 t=20ms 时调用。fn 的返回值是 10。\n</pre>\n\n<p><strong class=\"example\">示例 2</strong></p>\n\n<pre>\n<b>输入:</b>fn = (x) =&gt; x**2, args = [2], t = 100, cancelTime = 50\n<b>输出:</b>[]\n<b>解释:</b>fn(2) 从未被调用,因为 cancelTime50ms在延迟时间100ms之前。\n</pre>\n\n<p><strong class=\"example\">示例 3</strong></p>\n\n<pre>\n<b>输入:</b>fn = (x1, x2) =&gt; x1 * x2, args = [2,4], t = 30, cancelTime = 100\n<b>输出:</b>[{\"time\": 30, \"returned\": 8}]\n<b>解释:</b>fn(2) 从未被调用,因为 cancelTime50ms在延迟时间100ms之前。\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>fn 是一个函数</code></li>\n\t<li><code>args 是一个有效的 JSON 数组</code></li>\n\t<li><code>1 &lt;= args.length &lt;= 10</code></li>\n\t<li><code><font face=\"monospace\">20 &lt;= t &lt;= 1000</font></code></li>\n\t<li><code><font face=\"monospace\">10 &lt;= cancelT &lt;= 1000</font></code></li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 0,
"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, \"ruby\": false, \"bash\": false, \"swift\": false, \"golang\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"kotlin\": false, \"rust\": false, \"php\": false, \"typescript\": false, \"racket\": false, \"erlang\": false, \"elixir\": false, \"dart\": false}",
"topicTags": [],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "JavaScript",
"langSlug": "javascript",
"code": "/**\n * @param {Function} fn\n * @param {Array} args\n * @param {number} t\n * @return {Function}\n */\nvar cancellable = function(fn, args, t) {\n \n};\n\n/**\n * const result = []\n *\n * const fn = (x) => x * 5\n * const args = [2], t = 20, cancelT = 50\n *\n * const log = (...argsArr) => {\n * result.push(fn(...argsArr))\n * }\n * \n * const cancel = cancellable(fn, args, t);\n * \n * setTimeout(() => {\n * cancel()\n * console.log(result) // [{\"time\":20,\"returned\":10}]\n * }, cancelT)\n */",
"__typename": "CodeSnippetNode"
},
{
"lang": "TypeScript",
"langSlug": "typescript",
"code": "function cancellable(fn: Function, args: any[], t: number): Function {\n\n};\n\n/**\n * const result = []\n *\n * const fn = (x) => x * 5\n * const args = [2], t = 20, cancelT = 50\n *\n * const log = (...argsArr) => {\n * result.push(fn(...argsArr))\n * }\n * \n * const cancel = cancellable(fn, args, t);\n * \n * setTimeout(() => {\n * cancel()\n * console.log(result) // [{\"time\":20,\"returned\":10}]\n * }, cancelT)\n */",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"183\", \"totalSubmission\": \"216\", \"totalAcceptedRaw\": 183, \"totalSubmissionRaw\": 216, \"acRate\": \"84.7%\"}",
"hints": [],
"solution": null,
"status": null,
"sampleTestCase": "(x) => x * 5\n[2]\n20\n50",
"metaData": "{\n \"name\": \"cancellable\",\n \"params\": [\n {\n \"name\": \"fn\",\n \"type\": \"string\"\n },\n {\n \"type\": \"string\",\n \"name\": \"args\"\n },\n {\n \"type\": \"integer\",\n \"name\": \"t\"\n },\n {\n \"type\": \"integer\",\n \"name\": \"cancelT\"\n }\n ],\n \"return\": {\n \"type\": \"integer\"\n },\n \"languages\": [\n \"javascript\",\n \"typescript\"\n ],\n \"manual\": true\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [],
"enableRunCode": true,
"envInfo": "{\"javascript\":[\"JavaScript\",\"<p>\\u7248\\u672c\\uff1a<code>Node.js 16.13.2<\\/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\\/tree\\/fb4fdb984834421279aeb081df7af624d17c2a03\\\" target=\\\"_blank\\\"> datastructures-js\\/priority-queue@5.3.0<\\/a> \\u548c <a href=\\\"https:\\/\\/github.com\\/datastructures-js\\/queue\\/tree\\/e63563025a5a805aa16928cb53bcd517bfea9230\\\" target=\\\"_blank\\\"> datastructures-js\\/queue@4.2.1<\\/a>\\u3002<\\/p>\"],\"typescript\":[\"TypeScript\",\"<p>TypeScript 4.5.4<\\/p>\\r\\n\\r\\n<p>Compile Options: --alwaysStrict --strictBindCallApply --strictFunctionTypes --target ES2020<\\/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\\/tree\\/fb4fdb984834421279aeb081df7af624d17c2a03\\\" target=\\\"_blank\\\"> datastructures-js\\/priority-queue@5.3.0<\\/a> \\u548c <a href=\\\"https:\\/\\/github.com\\/datastructures-js\\/queue\\/tree\\/e63563025a5a805aa16928cb53bcd517bfea9230\\\" target=\\\"_blank\\\"> datastructures-js\\/queue@4.2.1<\\/a>\\u3002<\\/p>\"]}",
"book": null,
"isSubscribed": false,
"isDailyQuestion": false,
"dailyRecordStatus": null,
"editorType": "CKEDITOR",
"ugcQuestionId": null,
"style": "LEETCODE",
"exampleTestcases": "(x) => x * 5\n[2]\n20\n50\n(x) => x**2\n[2]\n100\n50\n(x1, x2) => x1 * x2\n[2,4]\n20\n100",
"__typename": "QuestionNode"
}
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,59 @@
{
"data": {
"question": {
"questionId": "2862",
"questionFrontendId": "2725",
"categoryTitle": "JavaScript",
"boundTopicId": 2300584,
"title": "Interval Cancellation",
"titleSlug": "interval-cancellation",
"content": "Given a function <code>fn,</code> an array of arguments&nbsp;<code>args</code>, and&nbsp;an interval time <code>t</code>, return a cancel function <code>cancelFn</code>. The function <code>fn</code> should be called with <code>args</code> immediately and then called again every&nbsp;<code>t</code> milliseconds&nbsp;until <code>cancelFn</code> is called.\n<p>&nbsp;</p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> fn = (x) =&gt; x * 2, args = [4], t = 20, cancelT = 110\n<strong>Output:</strong> \n[\n {&quot;time&quot;: 0, &quot;returned&quot;: 8},\n {&quot;time&quot;: 20, &quot;returned&quot;: 8},\n {&quot;time&quot;: 40, &quot;returned&quot;: 8},\n {&quot;time&quot;: 60, &quot;returned&quot;: 8},\n {&quot;time&quot;: 80, &quot;returned&quot;: 8},\n {&quot;time&quot;: 100, &quot;returned&quot;: 8}\n]\n<strong>Explanation:</strong> Every 20ms, fn(4) is called. Until t=110ms, then it is cancelled.\n\nconst cancel = cancellable(x =&gt; x * 2, [4], 20);\nsetTimeout(cancel, 110);\n\n1st fn call is at 0ms. fn(4) returns 8.\n2nd fn call is at 20ms. fn(4) returns 8.\n3rd fn call is at 40ms. fn(4) returns 8.\n4th fn call is at&nbsp;60ms. fn(4) returns 8.\n5th fn call is at 80ms. fn(4) returns 8.\n6th fn call is at 100ms. fn(4) returns 8.\n</pre>\n\n<p><strong class=\"example\">Example 2:</strong></p>\n\n<pre>\n<strong>Input:</strong> fn = (x1, x2) =&gt; (x1 * x2), args = [2, 5], t = 25, cancelT = 140\n<strong>Output:</strong> \n[\n {&quot;time&quot;: 0, &quot;returned&quot;: 10},\n {&quot;time&quot;: 25, &quot;returned&quot;: 10},\n {&quot;time&quot;: 50, &quot;returned&quot;: 10},\n {&quot;time&quot;: 75, &quot;returned&quot;: 10},\n {&quot;time&quot;: 100, &quot;returned&quot;: 10},\n {&quot;time&quot;: 125, &quot;returned&quot;: 10}\n]\n<strong>Explanation:</strong> Every 25ms, fn(2, 5) is called. Until t=140ms, then it is cancelled.\n1st fn call is at 0ms&nbsp;\n2nd fn call is at 25ms&nbsp;\n3rd fn call is at 50ms&nbsp;\n4th fn call is at&nbsp;75ms&nbsp;\n5th fn call is at 100ms&nbsp;\n6th fn call is at 125ms\nCancelled at 140ms\n</pre>\n\n<p><strong class=\"example\">Example 3:</strong></p>\n\n<pre>\n<strong>Input:</strong> fn = (x1, x2, x3) =&gt; (x1 + x2 + x3), args = [5, 1, 3], t = 50, cancelT = 180\n<strong>Output:</strong> \n[\n {&quot;time&quot;: 0, &quot;returned&quot;: 9},\n {&quot;time&quot;: 50, &quot;returned&quot;: 9},\n {&quot;time&quot;: 100, &quot;returned&quot;: 9},\n {&quot;time&quot;: 150, &quot;returned&quot;: 9}\n]\n<strong>Explanation:</strong> Every 50ms, fn(5, 1, 3) is called. Until t=180ms, then it is cancelled. \n1st fn call is at 0ms\n2nd fn call is at 50ms\n3rd fn call is at 100ms\n4th fn call is at&nbsp;150ms\nCancelled at 180ms\n</pre>\n\n<p>&nbsp;</p>\n<p><strong>Constraints:</strong></p>\n\n<ul>\n\t<li><code>fn is a function</code></li>\n\t<li><code>args is a valid JSON array</code></li>\n\t<li><code>1 &lt;= args.length &lt;= 10</code></li>\n\t<li><code><font face=\"monospace\">20 &lt;= t &lt;= 1000</font></code></li>\n\t<li><code><font face=\"monospace\">10 &lt;= cancelT &lt;= 1000</font></code></li>\n</ul>\n",
"translatedTitle": "间隔取消",
"translatedContent": "现给定一个函数 <code>fn</code>,一个参数数组 <code>args</code> 和一个时间间隔 <code>t</code>,返回一个取消函数 <code>cancelFn</code>。函数 <code>fn</code> 应该立即使用 <code>args</code> 调用,并且在每个 <code>t</code> 毫秒内再次调用,直到调用 <code>cancelFn</code>。\n<p>&nbsp;</p>\n\n<p><strong class=\"example\">示例 1</strong></p>\n\n<pre>\n<b>输入:</b>fn = (x) =&gt; x * 2, args = [4], t = 20, cancelT = 110\n<b>输出:</b>\n[\n {\"time\": 0, \"returned\": 8},\n {\"time\": 20, \"returned\": 8},\n {\"time\": 40, \"returned\": 8},\n {\"time\": 60, \"returned\": 8},\n {\"time\": 80, \"returned\": 8},\n {\"time\": 100, \"returned\": 8}\n]\n<strong>解释:</strong> 每隔 20ms调用 fn(4)。直到 t=110ms然后取消。\nconst cancel = cancellable(x =&gt; x * 2, [4], 20);\nsetTimeout(cancel, 110);\n第一次调用 fn 是在 0ms。fn(4) 返回 8。\n第二次调用 fn 是在 20ms。fn(4) 返回 8。\n第三次调用 fn 是在 40ms。fn(4) 返回 8。\n第四次调用 fn 是在&nbsp;60ms。fn(4) 返回 8。\n第五次调用 fn 是在 80ms。fn(4) 返回 8。\n第六次调用 fn 是在 100ms。fn(4) 返回 8。</pre>\n\n<p><strong class=\"example\">示例 2</strong></p>\n\n<pre>\n<b>输入:</b>fn = (x1, x2) =&gt; (x1 * x2), args = [2, 5], t = 25, cancelT = 140\n<strong>输出:</strong> \n[\n {\"time\": 0, \"returned\": 10},\n {\"time\": 25, \"returned\": 10},\n {\"time\": 50, \"returned\": 10},\n {\"time\": 75, \"returned\": 10},\n {\"time\": 100, \"returned\": 10},\n {\"time\": 125, \"returned\": 10}\n]\n<strong>解释:</strong>每隔 25ms调用 fn(2, 5)。直到 t=140ms然后取消。\n第一次调用 fn 是在 0ms\n第二次调用 fn 是在 25ms\n第三次调用 fn 是在 50ms\n第四次调用 fn 是在&nbsp;75ms\n第五次调用 fn 是在 100ms\n第六次调用 fn 是在 125ms\n在 140ms 取消\n</pre>\n\n<p><strong class=\"example\">示例 3</strong></p>\n\n<pre>\n<b>输入:</b>fn = (x1, x2, x3) =&gt; (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>每隔 50ms调用 fn(5, 1, 3)。直到 t=180ms然后取消。\n第一次调用 fn 是在 0ms\n第二次调用 fn 是在 50ms\n第三次调用 fn 是在 100ms\n第四次调用 fn 是在&nbsp;150ms\n在 180ms 取消\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>fn 是一个函数</code></li>\n\t<li><code>args 是一个有效的 JSON 数组</code></li>\n\t<li><code>1 &lt;= args.length &lt;= 10</code></li>\n\t<li><code><font face=\"monospace\">20 &lt;= t &lt;= 1000</font></code></li>\n\t<li><code><font face=\"monospace\">10 &lt;= cancelT &lt;= 1000</font></code></li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 0,
"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, \"ruby\": false, \"bash\": false, \"swift\": false, \"golang\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"kotlin\": false, \"rust\": false, \"php\": false, \"typescript\": false, \"racket\": false, \"erlang\": false, \"elixir\": false, \"dart\": false}",
"topicTags": [],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "JavaScript",
"langSlug": "javascript",
"code": "/**\n * @param {Function} fn\n * @param {Array} args\n * @param {number} t\n * @return {Function}\n */\nvar cancellable = function(fn, args, t) {\n \n};\n\n/**\n * const result = []\n *\n * const fn = (x) => x * 2\n * const args = [4], t = 20, cancelT = 110\n *\n * const start = performance.now()\n *\n * const log = (...argsArr) => {\n *\t\tconst val = fn(...argsArr)\n * result.push({\"time\": Math.floor(performance.now() - start), \"returned\": fn(...argsArr)})\n * }\n * \n * const cancel = cancellable(log, args, t);\n * \n * setTimeout(() => {\n * cancel()\n * console.log(result) // [\n * // {\"time\":0,\"returned\":8},\n * // {\"time\":20,\"returned\":8},\n * // {\"time\":40,\"returned\":8}, \n * // {\"time\":60,\"returned\":8},\n * // {\"time\":80,\"returned\":8},\n * // {\"time\":100,\"returned\":8}\n * // ]\n * }, cancelT)\n */",
"__typename": "CodeSnippetNode"
},
{
"lang": "TypeScript",
"langSlug": "typescript",
"code": "function cancellable(fn: Function, args: any[], t: number): Function {\n\n};\n\n/**\n * const result = []\n *\n * const fn = (x) => x * 2\n * const args = [4], t = 20, cancelT = 110\n *\n * const start = performance.now()\n *\n * const log = (...argsArr) => {\n *\t\tconst val = fn(...argsArr)\n * result.push({\"time\": Math.floor(performance.now() - start), \"returned\": fn(...argsArr)})\n * }\n * \n * const cancel = cancellable(log, args, t);\n * \n * setTimeout(() => {\n * cancel()\n * console.log(result) // [\n * // {\"time\":0,\"returned\":8},\n * // {\"time\":20,\"returned\":8},\n * // {\"time\":40,\"returned\":8}, \n * // {\"time\":60,\"returned\":8},\n * // {\"time\":80,\"returned\":8},\n * // {\"time\":100,\"returned\":8}\n * // ]\n * }, cancelT)\n */",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"139\", \"totalSubmission\": \"176\", \"totalAcceptedRaw\": 139, \"totalSubmissionRaw\": 176, \"acRate\": \"79.0%\"}",
"hints": [],
"solution": null,
"status": null,
"sampleTestCase": "(x) => x * 2\n[4]\n20\n110",
"metaData": "{\n \"name\": \"cancellable\",\n \"params\": [\n {\n \"name\": \"fn\",\n \"type\": \"string\"\n },\n {\n \"type\": \"string\",\n \"name\": \"args\"\n },\n {\n \"type\": \"integer\",\n \"name\": \"t\"\n },\n {\n \"type\": \"integer\",\n \"name\": \"cancelT\"\n }\n ],\n \"return\": {\n \"type\": \"integer\"\n },\n \"languages\": [\n \"javascript\",\n \"typescript\"\n ],\n \"manual\": true\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [],
"enableRunCode": true,
"envInfo": "{\"javascript\":[\"JavaScript\",\"<p>\\u7248\\u672c\\uff1a<code>Node.js 16.13.2<\\/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\\/tree\\/fb4fdb984834421279aeb081df7af624d17c2a03\\\" target=\\\"_blank\\\"> datastructures-js\\/priority-queue@5.3.0<\\/a> \\u548c <a href=\\\"https:\\/\\/github.com\\/datastructures-js\\/queue\\/tree\\/e63563025a5a805aa16928cb53bcd517bfea9230\\\" target=\\\"_blank\\\"> datastructures-js\\/queue@4.2.1<\\/a>\\u3002<\\/p>\"],\"typescript\":[\"TypeScript\",\"<p>TypeScript 4.5.4<\\/p>\\r\\n\\r\\n<p>Compile Options: --alwaysStrict --strictBindCallApply --strictFunctionTypes --target ES2020<\\/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\\/tree\\/fb4fdb984834421279aeb081df7af624d17c2a03\\\" target=\\\"_blank\\\"> datastructures-js\\/priority-queue@5.3.0<\\/a> \\u548c <a href=\\\"https:\\/\\/github.com\\/datastructures-js\\/queue\\/tree\\/e63563025a5a805aa16928cb53bcd517bfea9230\\\" target=\\\"_blank\\\"> datastructures-js\\/queue@4.2.1<\\/a>\\u3002<\\/p>\"]}",
"book": null,
"isSubscribed": false,
"isDailyQuestion": false,
"dailyRecordStatus": null,
"editorType": "CKEDITOR",
"ugcQuestionId": null,
"style": "LEETCODE",
"exampleTestcases": "(x) => x * 2\n[4]\n20\n110\n(x1, x2) => (x1 * x2)\n[2,5]\n25\n140\n(x1, x2, x3) => (x1 + x2 + x3)\n[5,1,3]\n50\n160",
"__typename": "QuestionNode"
}
}
}

View File

@@ -0,0 +1,59 @@
{
"data": {
"question": {
"questionId": "2864",
"questionFrontendId": "2727",
"categoryTitle": "JavaScript",
"boundTopicId": 2302689,
"title": "Is Object Empty",
"titleSlug": "is-object-empty",
"content": "<p>Given an object or an array, return if it is empty.</p>\n\n<ul>\n\t<li>An empty object contains no key-value pairs.</li>\n\t<li>An empty array contains no elements.</li>\n</ul>\n\n<p>You may assume the object or array is the output of&nbsp;<code>JSON.parse</code>.</p>\n\n<p>&nbsp;</p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> obj = {&quot;x&quot;: 5, &quot;y&quot;: 42}\n<strong>Output:</strong> false\n<strong>Explanation:</strong> The object has 2 key-value pairs so it is not empty.\n</pre>\n\n<p><strong class=\"example\">Example 2:</strong></p>\n\n<pre>\n<strong>Input:</strong> obj = {}\n<strong>Output:</strong> true\n<strong>Explanation:</strong> The object doesn&#39;t have any key-value pairs so it is empty.\n</pre>\n\n<p><strong class=\"example\">Example 3:</strong></p>\n\n<pre>\n<strong>Input:</strong> obj = [null, false, 0]\n<strong>Output:</strong> false\n<strong>Explanation:</strong> The array has 3 elements so it is not empty.\n</pre>\n\n<p>&nbsp;</p>\n<p><strong>Constraints:</strong></p>\n\n<ul>\n\t<li>&nbsp;<code>2 &lt;= JSON.stringify(obj).length &lt;= 10<sup>5</sup></code></li>\n</ul>\n\n<p>&nbsp;</p>\n<strong>Can you solve it in O(1) time?</strong>",
"translatedTitle": "判断对象是否为空",
"translatedContent": "<p>给定一个对象或数组,判断它是否为空。</p>\n\n<ul>\n\t<li>一个空对象不包含任何键值对。</li>\n\t<li>一个空数组不包含任何元素。</li>\n</ul>\n\n<p>你可以假设对象或数组是通过 <code>JSON.parse</code> 解析得到的。</p>\n\n<p>&nbsp;</p>\n\n<p><strong class=\"example\">示例 1</strong></p>\n\n<pre>\n<b>输入:</b>obj = {\"x\": 5, \"y\": 42}\n<b>输出:</b>false\n<b>解释:</b>The object has 2 key-value pairs so it is not empty.\n</pre>\n\n<p><strong class=\"example\">示例 2</strong></p>\n\n<pre>\n<b>输入:</b>obj = {}\n<b>输出:</b>true\n<b>解释:</b>The object doesn't have any key-value pairs so it is empty.\n</pre>\n\n<p><strong class=\"example\">示例 3</strong></p>\n\n<pre>\n<b>输入:</b>obj = [null, false, 0]\n<b>输出:</b>false\n<b>解释:</b>The array has 3 elements so it is not empty.\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li>&nbsp;<code>2 &lt;= JSON.stringify(obj).length &lt;= 10<sup>5</sup></code></li>\n</ul>\n\n<p>&nbsp;</p>\n<strong>你可以在 O(1) 时间复杂度内解决这个问题吗?</strong>",
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 0,
"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, \"ruby\": false, \"bash\": false, \"swift\": false, \"golang\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"kotlin\": false, \"rust\": false, \"php\": false, \"typescript\": false, \"racket\": false, \"erlang\": false, \"elixir\": false, \"dart\": false}",
"topicTags": [],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "JavaScript",
"langSlug": "javascript",
"code": "/**\n * @param {Object | Array} obj\n * @return {boolean}\n */\nvar isEmpty = function(obj) {\n \n};",
"__typename": "CodeSnippetNode"
},
{
"lang": "TypeScript",
"langSlug": "typescript",
"code": "function isEmpty(obj: Record<string, any> | any[]): boolean {\n\n};",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"165\", \"totalSubmission\": \"206\", \"totalAcceptedRaw\": 165, \"totalSubmissionRaw\": 206, \"acRate\": \"80.1%\"}",
"hints": [],
"solution": null,
"status": null,
"sampleTestCase": "{\"x\": 5, \"y\": 42}",
"metaData": "{\n \"name\": \"isEmpty\",\n \"params\": [\n {\n \"name\": \"obj\",\n \"type\": \"string\"\n }\n ],\n \"return\": {\n \"type\": \"boolean\"\n },\n \"manual\": true,\n \"languages\": [\n \"javascript\",\n \"typescript\"\n ]\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [],
"enableRunCode": true,
"envInfo": "{\"javascript\":[\"JavaScript\",\"<p>\\u7248\\u672c\\uff1a<code>Node.js 16.13.2<\\/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\\/tree\\/fb4fdb984834421279aeb081df7af624d17c2a03\\\" target=\\\"_blank\\\"> datastructures-js\\/priority-queue@5.3.0<\\/a> \\u548c <a href=\\\"https:\\/\\/github.com\\/datastructures-js\\/queue\\/tree\\/e63563025a5a805aa16928cb53bcd517bfea9230\\\" target=\\\"_blank\\\"> datastructures-js\\/queue@4.2.1<\\/a>\\u3002<\\/p>\"],\"typescript\":[\"TypeScript\",\"<p>TypeScript 4.5.4<\\/p>\\r\\n\\r\\n<p>Compile Options: --alwaysStrict --strictBindCallApply --strictFunctionTypes --target ES2020<\\/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\\/tree\\/fb4fdb984834421279aeb081df7af624d17c2a03\\\" target=\\\"_blank\\\"> datastructures-js\\/priority-queue@5.3.0<\\/a> \\u548c <a href=\\\"https:\\/\\/github.com\\/datastructures-js\\/queue\\/tree\\/e63563025a5a805aa16928cb53bcd517bfea9230\\\" target=\\\"_blank\\\"> datastructures-js\\/queue@4.2.1<\\/a>\\u3002<\\/p>\"]}",
"book": null,
"isSubscribed": false,
"isDailyQuestion": false,
"dailyRecordStatus": null,
"editorType": "CKEDITOR",
"ugcQuestionId": null,
"style": "LEETCODE",
"exampleTestcases": "{\"x\": 5, \"y\": 42}\n{}\n[null, false, 0]",
"__typename": "QuestionNode"
}
}
}

View File

@@ -0,0 +1,59 @@
{
"data": {
"question": {
"questionId": "2858",
"questionFrontendId": "2722",
"categoryTitle": "JavaScript",
"boundTopicId": 2300585,
"title": "Join Two Arrays by ID",
"titleSlug": "join-two-arrays-by-id",
"content": "<p>Given two arrays <code>arr1</code> and <code>arr2</code>, return a new&nbsp;array <code>joinedArray</code>. All the objects in each&nbsp;of the two inputs arrays will contain an&nbsp;<code>id</code>&nbsp;field that has an integer value.&nbsp;<code>joinedArray</code>&nbsp;is an array formed by merging&nbsp;<code>arr1</code> and <code>arr2</code> based on&nbsp;their <code>id</code>&nbsp;key. The length of&nbsp;<code>joinedArray</code> should be the length of unique values of <code>id</code>. The returned array should be sorted in&nbsp;<strong>ascending</strong>&nbsp;order based on the <code>id</code>&nbsp;key.</p>\n\n<p>If a given&nbsp;<code>id</code>&nbsp;exists in one array but not the other, the single object with that&nbsp;<code>id</code> should be included in the result array without modification.</p>\n\n<p>If two objects share an <code>id</code>, their properties should be merged into a single&nbsp;object:</p>\n\n<ul>\n\t<li>If a key only exists in one object, that single key-value pair should be included in the object.</li>\n\t<li>If a key is included in both objects, the value in the object from <code>arr2</code>&nbsp;should override the value from <code>arr1</code>.</li>\n</ul>\n\n<p>&nbsp;</p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> \narr1 = [\n&nbsp; {&quot;id&quot;: 1, &quot;x&quot;: 1},\n&nbsp; {&quot;id&quot;: 2, &quot;x&quot;: 9}\n], \narr2 = [\n {&quot;id&quot;: 3, &quot;x&quot;: 5}\n]\n<strong>Output:</strong> \n[\n&nbsp; {&quot;id&quot;: 1, &quot;x&quot;: 1},\n&nbsp; {&quot;id&quot;: 2, &quot;x&quot;: 9},\n {&quot;id&quot;: 3, &quot;x&quot;: 5}\n]\n<strong>Explanation:</strong> There are no duplicate ids so arr1 is simply concatenated with arr2.\n</pre>\n\n<p><strong class=\"example\">Example 2:</strong></p>\n\n<pre>\n<strong>Input:</strong> \narr1 = [\n {&quot;id&quot;: 1, &quot;x&quot;: 2, &quot;y&quot;: 3},\n {&quot;id&quot;: 2, &quot;x&quot;: 3, &quot;y&quot;: 6}\n], \narr2 = [\n {&quot;id&quot;: 2, &quot;x&quot;: 10, &quot;y&quot;: 20},\n {&quot;id&quot;: 3, &quot;x&quot;: 0, &quot;y&quot;: 0}\n]\n<strong>Output:</strong> \n[\n {&quot;id&quot;: 1, &quot;x&quot;: 2, &quot;y&quot;: 3},\n {&quot;id&quot;: 2, &quot;x&quot;: 10, &quot;y&quot;: 20},\n&nbsp; {&quot;id&quot;: 3, &quot;x&quot;: 0, &quot;y&quot;: 0}\n]\n<strong>Explanation:</strong> The two objects with id=1 and id=3 are included in the result array without modifiction. The two objects with id=2 are merged together. The keys from arr2 override the values in arr1.\n</pre>\n\n<p><strong class=\"example\">Example 3:</strong></p>\n\n<pre>\n<strong>Input:</strong> \narr1 = [\n {&quot;id&quot;: 1, &quot;b&quot;: {&quot;b&quot;: 94},&quot;v&quot;: [4, 3], &quot;y&quot;: 48}\n]\narr2 = [\n {&quot;id&quot;: 1, &quot;b&quot;: {&quot;c&quot;: 84}, &quot;v&quot;: [1, 3]}\n]\n<strong>Output:</strong> [\n {&quot;id&quot;: 1, &quot;b&quot;: {&quot;c&quot;: 84}, &quot;v&quot;: [1, 3], &quot;y&quot;: 48}\n]\n<strong>Explanation:</strong> The two objects with id=1 are merged together. For the keys &quot;b&quot; and &quot;v&quot; the values from arr2 are used. Since the key &quot;y&quot; only exists in arr1, that value is taken form arr1.</pre>\n\n<p>&nbsp;</p>\n<p><strong>Constraints:</strong></p>\n\n<ul>\n\t<li><code>arr1 and arr2 are valid JSON arrays</code></li>\n\t<li><code>Each object in arr1 and arr2 has a unique&nbsp;integer id key</code></li>\n\t<li><code>2 &lt;= JSON.stringify(arr1).length &lt;= 10<sup>6</sup></code></li>\n\t<li><code>2 &lt;= JSON.stringify(arr2).length &lt;= 10<sup>6</sup></code></li>\n</ul>\n",
"translatedTitle": "根据 ID 合并两个数组",
"translatedContent": "<p>现给定两个数组 <code>arr1</code> 和 <code>arr2</code> ,返回一个新的数组 <code>joinedArray</code> 。两个输入数组中的每个对象都包含一个 <code>id</code> 字段。<code>joinedArray</code> 是一个通过 <code>id</code> 将 <code>arr1</code> 和 <code>arr2</code> 连接而成的数组。<code>joinedArray</code> 的长度应为唯一值 <code>id</code> 的长度。返回的数组应按 <code>id</code> <strong>升序</strong> 排序。</p>\n\n<p>如果一个 <code>id</code> 存在于一个数组中但不存在于另一个数组中,则该对象应包含在结果数组中且不进行修改。</p>\n\n<p>如果两个对象共享一个 <code>id</code> ,则它们的属性应进行合并:</p>\n\n<ul>\n\t<li>如果一个键只存在于一个对象中,则该键值对应该包含在对象中。</li>\n\t<li>如果一个键在两个对象中都包含,则 <code>arr2</code> 中的值应覆盖 <code>arr1</code> 中的值。</li>\n</ul>\n\n<p>&nbsp;</p>\n\n<p><strong class=\"example\">示例 1</strong></p>\n\n<pre>\n<b>输入:</b>\narr1 = [\n&nbsp; {\"id\": 1, \"x\": 1},\n&nbsp; {\"id\": 2, \"x\": 9}\n], \narr2 = [\n {\"id\": 3, \"x\": 5}\n]\n<b>输出:</b>\n[\n&nbsp; {\"id\": 1, \"x\": 1},\n&nbsp; {\"id\": 2, \"x\": 9},\n {\"id\": 3, \"x\": 5}\n]\n<b>解释:</b>没有共同的 id因此将 arr1 与 arr2 简单地连接起来。\n</pre>\n\n<p><strong class=\"example\">示例 2</strong></p>\n\n<pre>\n<b>输入:</b>\narr1 = [\n {\"id\": 1, \"x\": 2, \"y\": 3},\n {\"id\": 2, \"x\": 3, \"y\": 6}\n], \narr2 = [\n {\"id\": 2, \"x\": 10, \"y\": 20},\n {\"id\": 3, \"x\": 0, \"y\": 0}\n]\n<b>输出:</b>\n[\n {\"id\": 1, \"x\": 2, \"y\": 3},\n {\"id\": 2, \"x\": 10, \"y\": 20},\n&nbsp; {\"id\": 3, \"x\": 0, \"y\": 0}\n]\n<b>解释:</b>id 为 1 和 id 为 3 的对象在结果数组中保持不变。id 为 2 的两个对象合并在一起。arr2 中的键覆盖 arr1 中的值。\n</pre>\n\n<p><strong class=\"example\">示例 3</strong></p>\n\n<pre>\n<b>输入:</b>\narr1 = [\n {\"id\": 1, \"b\": {\"b\": 94},\"v\": [4, 3], \"y\": 48}\n]\narr2 = [\n {\"id\": 1, \"b\": {\"c\": 84}, \"v\": [1, 3]}\n]\n<strong>输出:</strong> [\n {\"id\": 1, \"b\": {\"c\": 84}, \"v\": [1, 3], \"y\": 48}\n]\n<b>解释:</b>具有 id 为 1 的对象合并在一起。对于键 \"b\" 和 \"v\" ,使用 arr2 中的值。由于键 \"y\" 只存在于 arr1 中,因此取 arr1 的值。</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>arr1 和 arr2 都是有效的 JSON 数组</code></li>\n\t<li><code>在 arr1 和 arr2 中都有唯一的键值 id</code></li>\n\t<li><code>2 &lt;= JSON.stringify(arr1).length &lt;= 10<sup>6</sup></code></li>\n\t<li><code>2 &lt;= JSON.stringify(arr2).length &lt;= 10<sup>6</sup></code></li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Medium",
"likes": 0,
"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, \"ruby\": false, \"bash\": false, \"swift\": false, \"golang\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"kotlin\": false, \"rust\": false, \"php\": false, \"typescript\": false, \"racket\": false, \"erlang\": false, \"elixir\": false, \"dart\": false}",
"topicTags": [],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "JavaScript",
"langSlug": "javascript",
"code": "/**\n * @param {Array} arr1\n * @param {Array} arr2\n * @return {Array}\n */\nvar join = function(arr1, arr2) {\n \n};",
"__typename": "CodeSnippetNode"
},
{
"lang": "TypeScript",
"langSlug": "typescript",
"code": "function join(arr1: any[], arr2: any[]): any[] {\n\n};",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"115\", \"totalSubmission\": \"214\", \"totalAcceptedRaw\": 115, \"totalSubmissionRaw\": 214, \"acRate\": \"53.7%\"}",
"hints": [],
"solution": null,
"status": null,
"sampleTestCase": "[{\"id\": 1,\"x\": 1},{\"id\": 2,\"x\": 9}]\n[{\"id\": 3,\"x\": 5}]",
"metaData": "{\n \"name\": \"join\",\n \"params\": [\n {\n \"name\": \"arr1\",\n \"type\": \"string\"\n },\n {\n \"type\": \"string\",\n \"name\": \"arr2\"\n }\n ],\n \"return\": {\n \"type\": \"string\"\n },\n \"languages\": [\n \"javascript\",\n \"typescript\"\n ],\n \"manual\": true\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [],
"enableRunCode": true,
"envInfo": "{\"javascript\":[\"JavaScript\",\"<p>\\u7248\\u672c\\uff1a<code>Node.js 16.13.2<\\/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\\/tree\\/fb4fdb984834421279aeb081df7af624d17c2a03\\\" target=\\\"_blank\\\"> datastructures-js\\/priority-queue@5.3.0<\\/a> \\u548c <a href=\\\"https:\\/\\/github.com\\/datastructures-js\\/queue\\/tree\\/e63563025a5a805aa16928cb53bcd517bfea9230\\\" target=\\\"_blank\\\"> datastructures-js\\/queue@4.2.1<\\/a>\\u3002<\\/p>\"],\"typescript\":[\"TypeScript\",\"<p>TypeScript 4.5.4<\\/p>\\r\\n\\r\\n<p>Compile Options: --alwaysStrict --strictBindCallApply --strictFunctionTypes --target ES2020<\\/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\\/tree\\/fb4fdb984834421279aeb081df7af624d17c2a03\\\" target=\\\"_blank\\\"> datastructures-js\\/priority-queue@5.3.0<\\/a> \\u548c <a href=\\\"https:\\/\\/github.com\\/datastructures-js\\/queue\\/tree\\/e63563025a5a805aa16928cb53bcd517bfea9230\\\" target=\\\"_blank\\\"> datastructures-js\\/queue@4.2.1<\\/a>\\u3002<\\/p>\"]}",
"book": null,
"isSubscribed": false,
"isDailyQuestion": false,
"dailyRecordStatus": null,
"editorType": "CKEDITOR",
"ugcQuestionId": null,
"style": "LEETCODE",
"exampleTestcases": "[{\"id\": 1,\"x\": 1},{\"id\": 2,\"x\": 9}]\n[{\"id\": 3,\"x\": 5}]\n[{\"id\": 1,\"x\": 2,\"y\": 3},{\"id\": 2,\"x\": 3,\"y\": 6}]\n[{\"id\": 2,\"x\": 10,\"y\": 20},{\"id\": 3,\"x\": 0,\"y\": 0}]\n[{\"id\":1,\"b\":{\"b\": 94},\"v\":[4,3],\"y\":48}]\n[{\"id\":1,\"b\":{\"c\": 84},\"v\":[1,3]}]",
"__typename": "QuestionNode"
}
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,59 @@
{
"data": {
"question": {
"questionId": "2860",
"questionFrontendId": "2724",
"categoryTitle": "JavaScript",
"boundTopicId": 2302688,
"title": "Sort By",
"titleSlug": "sort-by",
"content": "<p>Given an array <code>arr</code> and a function <code>fn</code>, return a sorted array <code>sortedArr</code>. You can assume&nbsp;<code>fn</code>&nbsp;only returns numbers and those numbers determine the sort order of&nbsp;<code>sortedArr</code>. <code>sortedArray</code> must be sorted in <strong>ascending order</strong> by <code>fn</code> output.</p>\n\n<p>You may assume that <code>fn</code> will never duplicate numbers for a given array.</p>\n\n<p>&nbsp;</p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> arr = [5, 4, 1, 2, 3], fn = (x) =&gt; x\n<strong>Output:</strong> [1, 2, 3, 4, 5]\n<strong>Explanation:</strong> fn simply returns the number passed to it so the array is sorted in ascending order.\n</pre>\n\n<p><strong class=\"example\">Example 2:</strong></p>\n\n<pre>\n<strong>Input:</strong> arr = [{&quot;x&quot;: 1}, {&quot;x&quot;: 0}, {&quot;x&quot;: -1}], fn = (d) =&gt; d.x\n<strong>Output:</strong> [{&quot;x&quot;: -1}, {&quot;x&quot;: 0}, {&quot;x&quot;: 1}]\n<strong>Explanation:</strong> fn returns the value for the &quot;x&quot; key. So the array is sorted based on that value.\n</pre>\n\n<p><strong class=\"example\">Example 3:</strong></p>\n\n<pre>\n<strong>Input:</strong> arr = [[3, 4], [5, 2], [10, 1]], fn = (x) =&gt; x[1]\n<strong>Output:</strong> [[10, 1], [5, 2], [3, 4]]\n<strong>Explanation:</strong> arr is sorted in ascending order by number at index=1.&nbsp;\n</pre>\n\n<p>&nbsp;</p>\n<p><strong>Constraints:</strong></p>\n\n<ul>\n\t<li><code>arr is a valid JSON array</code></li>\n\t<li><code>fn is a function that returns a number</code></li>\n\t<li><code>1 &lt;=&nbsp;arr.length &lt;= 5 * 10<sup>5</sup></code></li>\n</ul>\n",
"translatedTitle": "排序方式",
"translatedContent": "<p>给定一个数组 <code>arr</code> 和一个函数 <code>fn</code>,返回一个排序后的数组 <code>sortedArr</code>。你可以假设 <code>fn</code> 只返回数字,并且这些数字决定了 <code>sortedArr</code> 的排序顺序。<code>sortedArr</code> 必须按照 <code>fn</code> 的输出值&nbsp;<strong>升序</strong> 排序。</p>\n\n<p>你可以假设对于给定的数组,<code>fn</code> 不会返回重复的数字。</p>\n\n<p>&nbsp;</p>\n\n<p><strong class=\"example\">示例 1</strong></p>\n\n<pre>\n<b>输入:</b>arr = [5, 4, 1, 2, 3], fn = (x) =&gt; x\n<b>输出:</b>[1, 2, 3, 4, 5]\n<b>解释:</b>fn 只是返回传入的数字,因此数组按升序排序。\n</pre>\n\n<p><strong class=\"example\">示例 2</strong></p>\n\n<pre>\n<b>输入:</b>arr = [{\"x\": 1}, {\"x\": 0}, {\"x\": -1}], fn = (d) =&gt; d.x\n<b>输出:</b>[{\"x\": -1}, {\"x\": 0}, {\"x\": 1}]\n<b>解释:</b>fn 返回 \"x\" 键的值,因此数组根据该值排序。\n</pre>\n\n<p><strong class=\"example\">示例 3</strong></p>\n\n<pre>\n<b>输入:</b>arr = [[3, 4], [5, 2], [10, 1]], fn = (x) =&gt; x[1]\n<b>输出:</b>[[10, 1], [5, 2], [3, 4]]\n<b>解释:</b>数组按照索引为 1 处的数字升序排序。\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>arr 是一个有效的 JSON 数组</code></li>\n\t<li><code>fn 是一个函数,返回一个数字</code></li>\n\t<li><code>1 &lt;=&nbsp;arr.length &lt;= 5 * 10<sup>5</sup></code></li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 0,
"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, \"ruby\": false, \"bash\": false, \"swift\": false, \"golang\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"kotlin\": false, \"rust\": false, \"php\": false, \"typescript\": false, \"racket\": false, \"erlang\": false, \"elixir\": false, \"dart\": false}",
"topicTags": [],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "JavaScript",
"langSlug": "javascript",
"code": "/**\n * @param {Array} arr\n * @param {Function} fn\n * @return {Array}\n */\nvar sortBy = function(arr, fn) {\n \n};",
"__typename": "CodeSnippetNode"
},
{
"lang": "TypeScript",
"langSlug": "typescript",
"code": "function sortBy(arr: any[], fn: Function): any[] {\n\n};",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"114\", \"totalSubmission\": \"133\", \"totalAcceptedRaw\": 114, \"totalSubmissionRaw\": 133, \"acRate\": \"85.7%\"}",
"hints": [],
"solution": null,
"status": null,
"sampleTestCase": "[5,4,1,2,3]\n(x) => x",
"metaData": "{\n \"name\": \"sortBy\",\n \"params\": [\n {\n \"name\": \"arr\",\n \"type\": \"string\"\n },\n {\n \"type\": \"string\",\n \"name\": \"fn\"\n }\n ],\n \"return\": {\n \"type\": \"integer\"\n },\n \"languages\": [\n \"javascript\",\n \"typescript\"\n ],\n \"manual\": true\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [],
"enableRunCode": true,
"envInfo": "{\"javascript\":[\"JavaScript\",\"<p>\\u7248\\u672c\\uff1a<code>Node.js 16.13.2<\\/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\\/tree\\/fb4fdb984834421279aeb081df7af624d17c2a03\\\" target=\\\"_blank\\\"> datastructures-js\\/priority-queue@5.3.0<\\/a> \\u548c <a href=\\\"https:\\/\\/github.com\\/datastructures-js\\/queue\\/tree\\/e63563025a5a805aa16928cb53bcd517bfea9230\\\" target=\\\"_blank\\\"> datastructures-js\\/queue@4.2.1<\\/a>\\u3002<\\/p>\"],\"typescript\":[\"TypeScript\",\"<p>TypeScript 4.5.4<\\/p>\\r\\n\\r\\n<p>Compile Options: --alwaysStrict --strictBindCallApply --strictFunctionTypes --target ES2020<\\/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\\/tree\\/fb4fdb984834421279aeb081df7af624d17c2a03\\\" target=\\\"_blank\\\"> datastructures-js\\/priority-queue@5.3.0<\\/a> \\u548c <a href=\\\"https:\\/\\/github.com\\/datastructures-js\\/queue\\/tree\\/e63563025a5a805aa16928cb53bcd517bfea9230\\\" target=\\\"_blank\\\"> datastructures-js\\/queue@4.2.1<\\/a>\\u3002<\\/p>\"]}",
"book": null,
"isSubscribed": false,
"isDailyQuestion": false,
"dailyRecordStatus": null,
"editorType": "CKEDITOR",
"ugcQuestionId": null,
"style": "LEETCODE",
"exampleTestcases": "[5,4,1,2,3]\n(x) => x\n[{\"x\":1},{\"x\": 0},{\"x\": -1}]\n(x) => x.x\n[[3,4],[5,2],[10,1]]\n(x) => x[1]",
"__typename": "QuestionNode"
}
}
}

File diff suppressed because one or more lines are too long