The following function is trying to find the nth to last element of a singly linked list.
nth
For example:
If the elements are
Recursive solution:
Node findKth (Node head, int count, int k) { if(head == null) return head; else { Node n =findKth(head.next,count,k); count++; if(count == k) return head; return n; } }