Define a minimal Iterator interface (e.g., hasNext(), next()) for integers without using IDE-generated scaffolding. Implement two iterator classes in Java:
(
-
FlattenIterator that iterates through a list of lists of integers, skipping empty lists;
(
-
FilterIterator that wraps any Integer iterator and yields only elements satisfying a provided predicate. Both must be robust to edge cases (empty input, single element, repeated hasNext() calls), throw appropriate exceptions when next() is invalid, and operate in O(
-
amortized time per element with O(
-
or O(depth) extra space as appropriate. Provide brief unit tests demonstrating correctness and discuss time/space complexity.