/**
* // This is the Iterator's API interface.
* // You should not implement it, or speculate about its implementation.
* function Iterator() {
* @ return {number}
* this.next = function() { // return the next number of the iterator
* ...
* };
*
* @return {boolean}
* this.hasNext = function() { // return true if it still has numbers
* ...
* };
* };
*//**
* @param {Iterator} iterator
*/varPeekingIterator=function(iterator){this.iterator = iterator;this.cache =null;};/**
* @return {number}
*/PeekingIterator.prototype.peek=function(){if(this.cache !==null)returnthis.cache;var cache =this.iterator.next();this.cache = cache;return cache;};/**
* @return {number}
*/PeekingIterator.prototype.next=function(){if(this.cache !==null){var cache =this.cache;this.cache =null;return cache;}returnthis.iterator.next();};/**
* @return {boolean}
*/PeekingIterator.prototype.hasNext=function(){if(this.cache !==null)returntrue;returnthis.iterator.hasNext();};/**
* Your PeekingIterator object will be instantiated and called as such:
* var obj = new PeekingIterator(arr)
* var param_1 = obj.peek()
* var param_2 = obj.next()
* var param_3 = obj.hasNext()
*/