public int lastIndexOf(E e) {
// Left as an exercise
// TODO : Implement this method
Node<E> current = tail;
not sure how to complete this for loop:
for (int i = size - 1; i >= 0; i--) {
if(e.equals(current))
return i;
}
return -1;
}
This program is asking me to create a lastIndexOf method for my own LinkedList interface. The lastIndexOf(E e) is supposed to return the index where the element e
is found. This is not the same as indexOf(E e)
because the algorithm requires me to look from the end of the list rather than the beginning