Flatten a deeply nested array whose elements are either JSON objects (dict) or more arrays. Return all objects in left-to-right order without using recursion.
Constraints
0 <= total elements across nesting <= 10^5
Each element is either a dict or a list
Nesting depth can be very large
Interviewer
Whenever you're ready, walk me through your approach or go straight to the code. The requirements are in the Question tab.