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.
It counts the position. We know that we need nth position from the tail. When we reach the tail we temp must be the tail-nth element. So we pass first nth element with this comparison so that temp always goes nth element behind current position. In these code head behaves as current.
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 →
It counts the position. We know that we need nth position from the tail. When we reach the tail we temp must be the tail-nth element. So we pass first nth element with this comparison so that temp always goes nth element behind current position. In these code head behaves as current.