@@ -0,0 +1,1119 @@
+package leetcode.peeking_iterator;%0A%0Aimport java.util.Iterator;%0A%0Aclass PeekingIterator implements Iterator%3CInteger%3E %7B%0A    %0A    private Iterator%3CInteger%3E mIterator;%0A    private Integer mNext;%0A    private boolean mHasNext;%0A    %0A    private final void nextInternal()%7B%0A        mHasNext = mIterator.hasNext();%0A        if(mHasNext)%7B%0A            mNext = mIterator.next();%0A        %7D%0A    %7D%0A%0A    public PeekingIterator(Iterator%3CInteger%3E iterator) %7B%0A        mIterator = iterator;%0A        nextInternal();%0A    %7D%0A%0A    // Returns the next element in the iteration without advancing the iterator.%0A    public Integer peek() %7B%0A        return mNext;%0A    %7D%0A%0A    // hasNext() and next() should behave the same as in the Iterator interface.%0A    // Override them if needed.%0A    @Override%0A    public Integer next() %7B%0A        if(mHasNext)%7B%0A            Integer ret = mNext;%0A            nextInternal();%0A            return ret;%0A        %7Delse%7B%0A            return null; // don't know how to handle%0A        %7D%0A    %7D%0A%0A    @Override%0A    public boolean hasNext() %7B%0A        return mHasNext;%0A    %7D%0A%0A    @Override%0A    public void remove() %7B%0A        %0A    %7D%0A%7D%0A

Add solution for 284. Peeking Iterator