Lists can contain lists and we have nested lists. But we don't like nested lists and want to flatten them. By flattening I mean create a list which does not contain any list, but elements of lists it contained before. I'll explain it more.
Input
An arbitrary size list which has the below properties:
- it can contain integers
- it can be empty
- it can contain lists which have the same properties
These are some examples of valid lists:
[]
[1, 2, 46]
[[], []]
[[[14], [[5]]], 4, [2]]
Output
The output must be a list, which is empty or only contains numbers. It must not contain lists. The output must be the flattened version of the input.
- all elements (beside empty lists) must be in the flattened version
- the order matters
Test cases:
[[3],[3, [[6]]]] -> [3, 3, 6]
[] -> []
[[], []] -> []
[[1, 4, 6], [1, [2, 67, [5, 7]]]] -> [1, 4, 6, 1, 2, 67, 5, 7]