Question: 5. Having a linked list with each node defined as below: class Node ( int data; Node next; Node(int d) [ data = d;

5. Having a linked list with each node defined as below: class Node ( int data; Node next; Node(int d) [ data = d; next = null; Write the code to find the Nth element from the end of the linked list. For example: Input: 1 -> 2-> 3-> 4, N=3 Output: 2 Input: 35->15-> 4-> 20, N=4 Output: 35
Step by Step Solution
There are 3 Steps involved in it
To find the Nth element from the end of a linked list you can use a twopointer approach Heres the Ja... View full answer
Get step-by-step solutions from verified subject matter experts
