You are viewing a single comment's thread. Return to all comments →
simple recursive solution in linear time
static int count = 0; static int val = 0; public static int getNode(SinglyLinkedListNode llist, int positionFromTail) { if(llist==null){ count=0; return 0; } getNode(llist.next, positionFromTail); if(positionFromTail==count){ val=llist.data; } count++; return val; }
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 →
simple recursive solution in linear time