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.
Get Node Value
Get Node Value
Sort by
recency
|
969 Discussions
|
Please Login in order to post a comment
I see a lot of solutions posted with double loops and/or a temporary stack of values. It's quite easy to save on repeats and memory with a single pass through the list and keeping track of 2 pointers. Give the one "searching for the end" a "head start" of the amount of provided positions and when you've reached the number, update the pointer to the node with the data.
This is Python Code using stack.
This is my solution
let arr = []
Python recursion solution explained.