Prompt: Given a list, the possible elements are integers or lists, which also contains integers or list of integers, make a class that can iterate over the next integer of the flatten list. The flatten list is a 1 dimensional version of the original list where all elements are integers.

Example:

Input: nestedList = [[1,1],2,[1,1]]
Output: [1,1,2,1,1]
Explanation: By calling next repeatedly until hasNext returns false, the order of elements returned by next should be: [1,1,2,1,1].
Input: nestedList = [1,[4,[6]]]
Output: [1,4,6]
Explanation: By calling next repeatedly until hasNext returns false, the order of elements returned by next should be: [1,4,6].

Solution: We can flatten the original list by using recursion and another list to hold the flatten version. If we iterate on an integer, we can append the integer on the flatten version of the list. If we iterate on a list of integers, we can recurse to the next state with the list.

Once we flatten the list, we can just iterate over the flattened list with an index. The runtime for this solution is O(n) where n is the number of integers in the original list.