{ "data": { "question": { "questionId": "2805", "questionFrontendId": "2695", "boundTopicId": null, "title": "Array Wrapper", "titleSlug": "array-wrapper", "content": "

Create a class ArrayWrapper that accepts an array of integers in it's constructor. This class should have two features:

\n\n\n\n

 

\n

Example 1:

\n\n
\nInput: nums = [[1,2],[3,4]], operation = "Add"\nOutput: 10\nExplanation:\nconst obj1 = new ArrayWrapper([1,2]);\nconst obj2 = new ArrayWrapper([3,4]);\nobj1 + obj2; // 10\n
\n\n

Example 2:

\n\n
\nInput: nums = [[23,98,42,70]], operation = "String"\nOutput: "[23,98,42,70]"\nExplanation:\nconst obj = new ArrayWrapper([23,98,42,70]);\nString(obj); // "[23,98,42,70]"\n
\n\n

Example 3:

\n\n
\nInput: nums = [[],[]], operation = "Add"\nOutput: 0\nExplanation:\nconst obj1 = new ArrayWrapper([]);\nconst obj2 = new ArrayWrapper([]);\nobj1 + obj2; // 0\n
\n\n

 

\n

Constraints:

\n\n\n", "translatedTitle": null, "translatedContent": null, "isPaidOnly": false, "difficulty": "Easy", "likes": 79, "dislikes": 9, "isLiked": null, "similarQuestions": "[]", "exampleTestcases": "[[1,2],[3,4]]\n\"Add\"\n[[23,98,42,70]]\n\"String\"\n[[],[]]\n\"Add\"", "categoryTitle": "JavaScript", "contributors": [], "topicTags": [], "companyTagStats": null, "codeSnippets": [ { "lang": "JavaScript", "langSlug": "javascript", "code": "/**\n * @param {number[]} nums\n */\nvar ArrayWrapper = function(nums) {\n \n};\n\nArrayWrapper.prototype.valueOf = function() {\n \n}\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 */", "__typename": "CodeSnippetNode" }, { "lang": "TypeScript", "langSlug": "typescript", "code": "class ArrayWrapper {\n\tconstructor(nums: number[]) {\n \n }\n\n\tvalueOf() {\n \n }\n\n\ttoString() {\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 */", "__typename": "CodeSnippetNode" } ], "stats": "{\"totalAccepted\": \"4.7K\", \"totalSubmission\": \"5.1K\", \"totalAcceptedRaw\": 4672, \"totalSubmissionRaw\": 5145, \"acRate\": \"90.8%\"}", "hints": [], "solution": { "id": "1926", "canSeeDetail": true, "paidOnly": false, "hasVideoSolution": false, "paidOnlyVideo": true, "__typename": "ArticleNode" }, "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, "enableTestMode": false, "enableDebugger": false, "envInfo": "{\"javascript\": [\"JavaScript\", \"

Node.js 16.13.2.

\\r\\n\\r\\n

Your code is run with --harmony flag, enabling new ES6 features.

\\r\\n\\r\\n

lodash.js library is included by default.

\\r\\n\\r\\n

For Priority Queue / Queue data structures, you may use 5.3.0 version of datastructures-js/priority-queue and 4.2.1 version of datastructures-js/queue.

\"], \"typescript\": [\"Typescript\", \"

TypeScript 4.5.4, Node.js 16.13.2.

\\r\\n\\r\\n

Your code is run with --harmony flag, enabling new ES2020 features.

\\r\\n\\r\\n

lodash.js library is included by default.

\"]}", "libraryUrl": null, "adminUrl": null, "challengeQuestion": null, "__typename": "QuestionNode" } } }