@@ -0,0 +1,1578 @@
+package data_structures.linked_lists;%0D%0A%0D%0A/*%0D%0A * Problem Statement:%0D%0A * Youre given the pointer to the head node of a linked list and a specific%0D%0A * position. Counting backwards from the tail node of the linked list, get the%0D%0A * value of the node at the given position. A position of 0 corresponds to the%0D%0A * tail, 1 corresponds to the node before the tail and so on.%0D%0A * %0D%0A * Input Format:%0D%0A * You have to complete the int GetNode(Node* head, int positionFromTail) method%0D%0A * which takes two arguments - the head of the linked list and the position of%0D%0A * the node from the tail. positionFromTail will be at least 0 and less than the%0D%0A * number of nodes in the list. You should NOT read any input from%0D%0A * stdin/console.%0D%0A * %0D%0A * Constraints:%0D%0A * Position will be a valid element in linked list.%0D%0A * %0D%0A * Output Format:%0D%0A * Find the node at the given position counting backwards from the tail. Then%0D%0A * return the data contained in this node. Do NOT print anything to%0D%0A * stdout/console.%0D%0A * %0D%0A * Sample Input: %0D%0A * 1 -%3E 3 -%3E 5 -%3E 6 -%3E NULL, positionFromTail = 0%0D%0A * 1 -%3E 3 -%3E 5 -%3E 6 -%3E NULL, positionFromTail = 2%0D%0A * %0D%0A * Sample Output: %0D%0A * 6%0D%0A * 3%0D%0A */%0D%0Apublic class GetNodeValue %7B%0D%0A%0D%0A%09int GetNode(Node head,int n) %7B%0D%0A%0D%0A%09    int numNodes = 0;%0D%0A%09    %0D%0A%09    Node runner = head;%0D%0A%09    while (runner.next != null) %7B%0D%0A%09        numNodes++;%0D%0A%09        runner = runner.next;%0D%0A%09    %7D%0D%0A%09    %0D%0A%09    runner = head;%0D%0A%09    int nodesFromHead = numNodes - n;%0D%0A%09    while (nodesFromHead %3E 0) %7B%0D%0A%09        runner = runner.next;%0D%0A%09        nodesFromHead--;%0D%0A%09    %7D%0D%0A%09    return runner.data;%0D%0A%09%7D%0D%0A%7D

Add GetNodeValue