public static Object nthToLast(int n, LinkedList list)
{
int len = list.size();
if(n<0 || len < n){
return null;
}
return list.get(len-n);
}
1
solved Check my solution for How to find nth element from the end of a singly linked list [closed]