Object-Oriented Programming · C3.ai · Medium
You are handed a nested list. Every element of it is either a single integer or a list, and any such inner list can itself hold integers or further lists. Write an iterator class that walks through this structure and yields all of its integers one at a time, in the order they would appear if the nesting were flattened. The class must expose two methods: next, which returns the next integer in that flattened sequence, and hasNext, which reports whether any integers remain to…