Flatten Completely
items is a list whose elements are integers or further lists, nested to any depth. Return one flat list holding every integer in the order it is met when reading items from left to right and going into each inner list where it occurs. Empty inner lists contribute nothing, and if there are no integers at all the result is an empty list.
For example, [1, [2, [3, 4]], 5] gives [1, 2, 3, 4, 5].
Example 1
items [1,[2,[3,4]],5]
returns [1,2,3,4,5]
Reading left to right and diving into each inner list gives 1, 2, 3, 4, 5.
Example 2
items [[],[1],[[2],[]],3]
returns [1,2,3]
Only 1, 2 and 3 are integers; the empty lists are skipped.
Constraints
itemsholds at most 100 integers and at most 50 lists in total- Lists are nested at most 10 levels deep
-100 <= value <= 100for every integer
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.