2023-06-02 01:00:40 +08:00
{
"data" : {
"question" : {
"questionId" : "2805" ,
"questionFrontendId" : "2695" ,
"categoryTitle" : "JavaScript" ,
"boundTopicId" : 2275511 ,
"title" : "Array Wrapper" ,
"titleSlug" : "array-wrapper" ,
2023-12-09 18:42:21 +08:00
"content" : "<p>Create a class <code>ArrayWrapper</code> that accepts an array of integers in its constructor. This class should have two features:</p>\n\n<ul>\n\t<li>When two instances of this class are added together with the <code>+</code> operator, the resulting value is the sum of all the elements in both arrays.</li>\n\t<li>When the <code>String()</code> function is called on the instance, it will return a comma separated string surrounded by brackets. For example, <code>[1,2,3]</code>.</li>\n</ul>\n\n<p> </p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> nums = [[1,2],[3,4]], operation = "Add"\n<strong>Output:</strong> 10\n<strong>Explanation:</strong>\nconst obj1 = new ArrayWrapper([1,2]);\nconst obj2 = new ArrayWrapper([3,4]);\nobj1 + obj2; // 10\n</pre>\n\n<p><strong class=\"example\">Example 2:</strong></p>\n\n<pre>\n<strong>Input:</strong> nums = [[23,98,42,70]], operation = "String"\n<strong>Output:</strong> "[23,98,42,70]"\n<strong>Explanation:</strong>\nconst obj = new ArrayWrapper([23,98,42,70]);\nString(obj); // "[23,98,42,70]"\n</pre>\n\n<p><strong class=\"example\">Example 3:</strong></p>\n\n<pre>\n<strong>Input:</strong> nums = [[],[]], operation = "Add"\n<strong>Output:</strong> 0\n<strong>Explanation:</strong>\nconst obj1 = new ArrayWrapper([]);\nconst obj2 = new ArrayWrapper([]);\nobj1 + obj2; // 0\n</pre>\n\n<p> </p>\n<p><strong>Constraints:</strong></p>\n\n<ul>\n\t<li><code>0 <= nums.length <= 1000</code></li>\n\t<li><code>0 <= nums[i] <= 1000</code></li>\n\t<li><code>Note: nums is the array passed to the constructor</code></li>\n</ul>\n" ,
2023-06-02 01:00:40 +08:00
"translatedTitle" : "包装数组" ,
"translatedContent" : "<p>创建一个名为 <code>ArrayWrapper</code> 的类,它在其构造函数中接受一个整数数组作为参数。该类应具有以下两个特性:</p>\n\n<ul>\n\t<li>当使用 <code>+</code> 运算符将两个该类的实例相加时,结果值为两个数组中所有元素的总和。</li>\n\t<li>当在实例上调用 <code>String()</code> 函数时,它将返回一个由逗号分隔的括在方括号中的字符串。例如,<code>[1,2,3]</code> 。</li>\n</ul>\n\n<p> </p>\n\n<p><strong class=\"example\">示例 1: </strong></p>\n\n<pre>\n<b>输入:</b>nums = [[1,2],[3,4]], operation = \"Add\"\n<b>输出:</b>10\n<b>解释:</b>\nconst obj1 = new ArrayWrapper([1,2]);\nconst obj2 = new ArrayWrapper([3,4]);\nobj1 + obj2; // 10\n</pre>\n\n<p><strong class=\"example\">示例 2: </strong></p>\n\n<pre>\n<b>输入:</b>nums = [[23,98,42,70]], operation = \"String\"\n<b>输出:</b>\"[23,98,42,70]\"\n<strong>解释:</strong>\nconst obj = new ArrayWrapper([23,98,42,70]);\nString(obj); // \"[23,98,42,70]\"\n</pre>\n\n<p><strong class=\"example\">示例 3: </strong></p>\n\n<pre>\n<b>输入:</b>nums = [[],[]], operation = \"Add\"\n<b>输出:</b>0\n<strong>解释:</strong>\nconst obj1 = new ArrayWrapper([]);\nconst obj2 = new ArrayWrapper([]);\nobj1 + obj2; // 0\n</pre>\n\n<p> </p>\n\n<p><b>提示:</b></p>\n\n<ul>\n\t<li><code>0 <= nums.length <= 1000</code></li>\n\t<li><code>0 <= nums[i] <= 1000</code></li>\n\t<li><code>注意: nums 是传递给构造函数的数组。</code></li>\n</ul>\n" ,
"isPaidOnly" : false ,
"difficulty" : "Easy" ,
2023-12-09 18:42:21 +08:00
"likes" : 3 ,
2023-06-02 01:00:40 +08:00
"dislikes" : 0 ,
"isLiked" : null ,
"similarQuestions" : "[]" ,
"contributors" : [ ] ,
2023-12-09 18:42:21 +08:00
"langToValidPlayground" : "{\"cpp\": false, \"java\": true, \"python\": true, \"python3\": false, \"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}" ,
2023-06-02 01:00:40 +08:00
"topicTags" : [ ] ,
"companyTagStats" : null ,
"codeSnippets" : [
{
"lang" : "JavaScript" ,
"langSlug" : "javascript" ,
2023-12-09 18:42:21 +08:00
"code" : "/**\n * @param {number[]} nums\n * @return {void}\n */\nvar ArrayWrapper = function(nums) {\n \n};\n\n/**\n * @return {number}\n */\nArrayWrapper.prototype.valueOf = function() {\n \n}\n\n/**\n * @return {string}\n */\nArrayWrapper.prototype.toString = function() {\n \n}\n\n/**\n * const obj1 = new ArrayWrapper([1,2]);\n * const obj2 = new ArrayWrapper([3,4]);\n * obj1 + obj2; // 10\n * String(obj1); // \"[1,2]\"\n * String(obj2); // \"[3,4]\"\n */" ,
2023-06-02 01:00:40 +08:00
"__typename" : "CodeSnippetNode"
} ,
{
"lang" : "TypeScript" ,
"langSlug" : "typescript" ,
2023-12-09 18:42:21 +08:00
"code" : "class ArrayWrapper {\n \n\tconstructor(nums: number[]) {\n \n }\n\n\tvalueOf(): number {\n \n }\n\n\ttoString(): string {\n \n }\n};\n\n/**\n * const obj1 = new ArrayWrapper([1,2]);\n * const obj2 = new ArrayWrapper([3,4]);\n * obj1 + obj2; // 10\n * String(obj1); // \"[1,2]\"\n * String(obj2); // \"[3,4]\"\n */" ,
2023-06-02 01:00:40 +08:00
"__typename" : "CodeSnippetNode"
}
] ,
2023-12-09 19:57:46 +08:00
"stats" : "{\"totalAccepted\": \"2.7K\", \"totalSubmission\": \"3.5K\", \"totalAcceptedRaw\": 2707, \"totalSubmissionRaw\": 3482, \"acRate\": \"77.7%\"}" ,
2023-06-02 01:00:40 +08:00
"hints" : [ ] ,
"solution" : null ,
"status" : null ,
"sampleTestCase" : "[[1,2],[3,4]]\n\"Add\"" ,
"metaData" : "{\n \"name\": \"ArrayWrapper\",\n \"params\": [\n {\n \"name\": \"nums\",\n \"type\": \"integer[][]\"\n },\n {\n \"type\": \"string\",\n \"name\": \"operation\"\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 ,
2023-12-09 18:42:21 +08:00
"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 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\\/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>\"]}" ,
2023-06-02 01:00:40 +08:00
"book" : null ,
"isSubscribed" : false ,
"isDailyQuestion" : false ,
"dailyRecordStatus" : null ,
"editorType" : "CKEDITOR" ,
"ugcQuestionId" : null ,
"style" : "LEETCODE" ,
"exampleTestcases" : "[[1,2],[3,4]]\n\"Add\"\n[[23,98,42,70]]\n\"String\"\n[[],[]]\n\"Add\"" ,
"__typename" : "QuestionNode"
}
}
}