Given a nested array of integers, return a single array containing every integer in left-to-right order. A nested array is an array whose elements are either an integer or another nested array. The nesting can be of arbitrary depth. The interviewer expects two solutions: one written recursively, and one written iteratively (no recursion). The reference solution shows both. `flatten([1, [2, [3, 4], 5], 6]) -> [1, 2, 3, 4, 5, 6] flatten([[1, 2, 3], [4, 5], [6]]) -> [1, 2, 3, 4, 5, 6] flatten([]) -> [] This question was reported from a Roblox Frontend Engineer phone screen (June 2025). The candidate had to write both a recursive and a non-recursive (stack-based) version on the same call.
The grader uses depth-2 inputs (number[][]); your recursive solution should still generalize to arbitrary depth — that is what the interviewer evaluates.