Nested Array Generator — LeetCode 2649 Python Solution

MediumJavaScript
Problem
#2649
Reading time
2 min

The problem

Given a multi-dimensional array of integers, return a generator object which yields integers in the same order as inorder traversal. A multi-dimensional array is a recursive data structure that contains both integers and other multi-dimensional arrays.

Example

Input
arr = [[[6]],[1,3],[]]
Output
[6,1,3]
Explanation
const generator = inorderTraversal(arr);

Complexity

MeasureComplexity
TimeO(n)
SpaceO(1) to O(n) auxiliary

Related problems

Frequently asked questions

How hard is LeetCode 2649. Nested Array Generator?
LeetCode 2649. Nested Array Generator is rated Medium on LeetCode.
What topics does LeetCode 2649. Nested Array Generator cover?
LeetCode 2649. Nested Array Generator is tagged JavaScript on LeetCode.

Stuck on problems like this in a live interview?

Stealth Interview is a desktop app for macOS and Windows. It reads the problem off your screen and returns a working solution with a step-by-step explanation and its time and space complexity — invisible to screen sharing.

Get Stealth Interview