This question evaluates implementation skills with Java generics, the iterator pattern and API design, along with unit testing and complexity analysis in the Coding & Algorithms domain.
Coinbase
Jul 31, 2025, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
0
0
In Java, write everything from scratch (no IDE scaffolding):
Define a generic Iterator
<T>
interface with hasNext() and next().
Implement ArrayIterator
<T>
over a fixed array.
Implement PeekingIterator
<T>
that wraps any Iterator
<T>
and adds peek() without advancing.
Provide minimal unit tests that compile and run, covering empty input, single element, multiple elements, and calling next() when no elements remain. Analyze time/space complexity and edge cases.