Here I came up with a common interview question that you might get in an interview.

So the question goes as follows,

Write a function, that when given a multi-level array, flattens it into a 1D array.

Sample Input — [1, 2, [3, [4, 5]], 6]

Sample Output — [1, 2, 3, 4, 5, 6]

One of the possible ways that we can use to solve this is a recursive approach because we really don't know how many levels of nested arrays are going to be there.

So, I came up with the following solution using LINQ.

Please find the full solution with unit testing in Github.

Thank you & Good Luck!

About