Given a 2D array (an array of arrays of numbers), flatten it into a single 1D array.
The input is only one level deep — each element of the outer array is itself an array of numbers. Concatenate all the inner arrays in order to produce the result.
arr = [[1, 2], [3, 4], [5, 6]][1, 2, 3, 4, 5, 6]arr = [[1], [2, 3, 4], [5]][1, 2, 3, 4, 5]arr = [[], [1, 2], []][1, 2]0 <= arr.length <= 10^30 <= arr[i].length <= 10^3-10^6 <= arr[i][j] <= 10^6Total elements across all inner arrays <= 10^5Run your code to see results
Use Cmd+Enter to run