Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Flatten a Nested Array
00:00
5 left

Flatten a Nested Array

EasyPython

Problem

Given a nested array arr, return a flat array of all non-array elements in left-to-right order. Elements can be nested to arbitrary depth, and empty arrays should not add anything to the result.

Constraints

  • 0 <= len(arr) <= 10^4
  • Total nested structure size is at most 10^5
  • Nesting depth is at most 10^3
  • Each element is either an integer or a list
Interviewer

Your question is Flatten a Nested Array. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.