MediumNo. 2649

Nested Array Generator — LeetCode 2649 Python Solution

Topics
JavaScript
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

Time
O(n)
Space · auxiliary
O(1) to O(n)

Related problems

Related problems
No.ProblemDifficulty
2644Find the Maximum Divisibility ScoreEasy
0057Insert IntervalMedium
0192Word FrequencyMedium
0193Valid Phone NumbersEasy
0194Transpose FileMedium
0195Tenth LineEasy

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.

Free to download. Check it runs on your machine, then pick a plan.