I think there is a problem in your code: if there is no element left, peekVal should be set to null in call(), or when I keep calling next() or peek() after all the elements are iterated, it will keep showing the last element.
Posts made by wipa1989
RE: My Java solution without setting the peeked value to null
RE: Why when I use LinkedList, it will TLE, but when I use ArrayList, it accepts?
actually, when remove an element in arraylist, the elements after the o will be moved forward. here it costs more time than linkedList. So I don't why arraylist is better than linkedlist. Or in this question, find is more frequent than delete and find needs more concern than delete?