You are viewing a single comment's thread. Return to all comments →
My Java 8 Solution
public static int getNode(SinglyLinkedListNode llist, int positionFromTail) { int lenght = 0; SinglyLinkedListNode counterList = llist; while (counterList != null) { lenght++; counterList = counterList.next; } int positionFromHead = lenght - positionFromTail - 1; int index = 0; SinglyLinkedListNode node = llist; while (index < positionFromHead) { node = node.next; index++; } return node.data; }
Seems like cookies are disabled on this browser, please enable them to open this website
Get Node Value
You are viewing a single comment's thread. Return to all comments →
My Java 8 Solution