{ "data": { "question": { "questionId": "2783", "questionFrontendId": "2649", "boundTopicId": null, "title": "Nested Array Generator", "titleSlug": "nested-array-generator", "content": "
Given a multi-dimensional array of integers, return a generator object which yields integers in the same order as inorder traversal.
\n\nA multi-dimensional array is a recursive data structure that contains both integers and other multi-dimensional arrays.
\n\ninorder traversal iterates over each array from left to right, yielding any integers it encounters or applying inorder traversal to any arrays it encounters.
\n\n\n
Example 1:
\n\n\nInput: arr = [[[6]],[1,3],[]]\nOutput: [6,1,3]\nExplanation:\nconst generator = inorderTraversal(arr);\ngenerator.next().value; // 6\ngenerator.next().value; // 1\ngenerator.next().value; // 3\ngenerator.next().done; // true\n\n\n
Example 2:
\n\n\nInput: arr = []\nOutput: []\nExplanation: There are no integers so the generator doesn't yield anything.\n\n\n
\n
Constraints:
\n\n0 <= arr.flat().length <= 105
0 <= arr.flat()[i] <= 105
maxNestingDepth <= 105
Node.js 16.13.2
.
Your code is run with --harmony
flag, enabling new ES6 features.
lodash.js library is included by default.
\\r\\n\\r\\nFor 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
.
Your code is run with --harmony
flag, enabling new ES2020 features.
lodash.js library is included by default.
\"]}", "libraryUrl": null, "adminUrl": null, "challengeQuestion": null, "__typename": "QuestionNode" } } }