@@ -0,0 +1,1077 @@
+/**%0A * Problem Link: https://leetcode.com/problems/peeking-iterator/%0A */%0A// Java Iterator interface reference:%0A// https://docs.oracle.com/javase/8/docs/api/java/util/Iterator.html%0Aclass PeekingIterator implements Iterator%3CInteger%3E %7B%0A%0A    private Integer current;%0A    private Iterator%3CInteger%3E iterator;%0A%0A%09public PeekingIterator(Iterator%3CInteger%3E iterator) %7B%0A%09    // initialize any member here.%0A%09    this.iterator = iterator;%0A%09    if(this.iterator.hasNext()) %7B%0A%09        current = this.iterator.next();%0A%09    %7D else %7B%0A%09        current = null;%0A%09    %7D%0A%09%7D%0A%0A    // Returns the next element in the iteration without advancing the iterator.%0A%09public Integer peek() %7B%0A        return current;%0A%09%7D%0A%0A%09// hasNext() and next() should behave the same as in the Iterator interface.%0A%09// Override them if needed.%0A%09@Override%0A%09public Integer next() %7B%0A%09    Integer ret = current;%0A%09    if(this.iterator.hasNext()) %7B%0A%09        current = this.iterator.next();%0A%09    %7D else %7B%0A%09        current = null;%0A%09    %7D%0A%09    return ret;%0A%09%7D%0A%0A%09@Override%0A%09public boolean hasNext() %7B%0A%09    return this.current != null;%0A%09%7D%0A%7D%0A

Create Peeking_Iterator.java