LeetCode 284: Peeking Iterator
Problem Restatement We are given an existing iterator with these operations: next() hasNext() We need to design a new iterator called PeekingIterator that also supports: peek() peek() should return the next element without moving the iterator forward. That means calling: peek() multiple times should always return the same value until: next() is called. The official statement defines peek() as retrieving the next element without advancing the iterator. The wrapped iterator...