Implement iterators and write tests in Java
Company: Coinbase
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: Medium
Interview Round: Onsite
In Java, write everything from scratch (no IDE scaffolding):
1) Define a generic Iterator<T> interface with hasNext() and next().
2) Implement ArrayIterator<T> over a fixed array.
3) Implement PeekingIterator<T> that wraps any Iterator<T> and adds peek() without advancing.
4) 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.
Quick Answer: 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.