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.
yeah. so we have two pointers. one is a iteration pointer and the other will be behind it by requested number of elements. so for example
lets say we need to get value of 3rd element from tail.
we start incrementing second pointer after 3rd element alongside with iteration pointer.
When iteration pointer gets to the end(tail) second pointer is going to be pointing to 3rd element from it. which is our answer.
hope that helps.
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 →
yeah. so we have two pointers. one is a iteration pointer and the other will be behind it by requested number of elements. so for example lets say we need to get value of 3rd element from tail. we start incrementing second pointer after 3rd element alongside with iteration pointer. When iteration pointer gets to the end(tail) second pointer is going to be pointing to 3rd element from it. which is our answer. hope that helps.