The question itself is fine, pretty standard iterator design.
Start by clarifying requirements and edge cases (e.g., empty streams, null inputs, thread safety). Then design a class that maintains a list of active iterators, a current index, and a method to advance to the next non-exhausted iterator. Implement has_next() and next() with careful handling of iterator removal and index wrapping.
Pro tip: Demonstrate awareness of real-world constraints: discuss how to handle concurrent modification, memory efficiency for large streams, and whether to pre-fetch elements for has_next() to avoid side effects. Mention that in production, you'd likely use a library like Guava's Iterators.concat or mergeSorted, but implementing it shows deeper understanding.
Ask about input types (byte/char iterators), whether streams can be added/removed dynamically, thread safety, and performance expectations. Confirm that has_next() should not consume elements.
Propose maintaining a list of iterators, an index pointer, and possibly a cached next element. Explain how to skip exhausted iterators efficiently, e.g., by removing them from the list or advancing the index with modulo arithmetic.
Describe the algorithm: has_next() scans from current index to find a non-exhausted iterator; next() returns the element from that iterator and advances the index. Handle the case where all iterators are exhausted.
Discuss time complexity: O(k) worst-case for has_next() where k is number of streams, but amortized O(1) if exhausted iterators are removed. Space complexity O(k). Compare with alternative approaches like pre-fetching or using a queue.
Walk through examples: empty list of streams, all streams empty, streams of different lengths, and interleaved exhaustion. Mention unit tests for these scenarios.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.