Problem List|11. Flatten Deeply Nested ArrayEasy

11. Flatten Deeply Nested Array

JavaScript CoreArrays
Given a multi-dimensional array `arr` of arbitrary depth, return a flat, 1-dimensional array containing all elements in order. You may not use the native `Array.prototype.flat` method.
Example 1:
Input: arr = [1, [2, [3, 4], 5], 6]
Output: [1, 2, 3, 4, 5, 6]
Explanation: All nested brackets are unwrapped into a flat array.

Constraints:

  • 0 <= arr.length <= 10^4
  • Depth of nesting can reach up to 100.
Integrity: 100%
Loading...
Input Arguments:
arr = [1, [2, [3, 4], 5], 6]
Expected Output:
[1, 2, 3, 4, 5, 6]