We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Mysolution:Iteratesthroughlisttwice.Solutionbelowisbetter:)intGetNode(Nodehead,intn){// This is a "method-only" submission. // You only need to complete this method.NodecurrentNode=head;intindex=0;while(currentNode.next!=null){currentNode=currentNode.next;index++;}currentNode=head;for(inti=0;i<index-n;i++){currentNode=currentNode.next;}returncurrentNode.data;}
Cookie support is required to access HackerRank
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 →