You are viewing a single comment's thread. Return to all comments →
int length,answer; int GetNode(Node head,int n) { genNodeHelper(head,n,0); return answer; } void genNodeHelper(Node head, int n, int index){ if(head == null) length = index-1; else genNodeHelper(head.next, n, index+1); if(length - n == index) answer = head.data; }
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 →
How about this recursive solution?