
Flatten a nested list containing integers and sublists into a single list of integers in left-to-right order. The nesting can be arbitrarily deep, and empty lists may appear anywhere.
[1, [2, 3], 4]Output[1, 2, 3, 4]WhyExpand the inner list in place.[[1, [2]], [], [3, [4, [5]]]]Output[1, 2, 3, 4, 5]WhyTraverse every nested level and ignore empty lists.Input length can be up to 10^4Each element is either an integer or another nested listPreserve left-to-right orderNesting depth may be greater than 1