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.
Salcio's solution will only have a complexity of O(n). It is actually quicker than your solution, which will iterate through the list twice. Instead, Salcio's will only iterate through it once.
The while loop will run current through the entire list and stop once it has reached the end.
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 →
Salcio's solution will only have a complexity of O(n). It is actually quicker than your solution, which will iterate through the list twice. Instead, Salcio's will only iterate through it once.
The while loop will run
current
through the entire list and stop once it has reached the end.