Search
⌘K

Leetcode 284. Peeking Iterator

Wrap an existing iterator to add a peek() operation that returns the next element without advancing the iterator, while preserving correct behavior for next() and hasNext() across multiple calls. The challenge is to maintain the iterator state so peek() can be called repeatedly without consuming the element (and to generalize this design for any type).


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.