Implement a function that finds the nth node in a linked list, counting from the end. Your function should take a linked list (its head element) and
n
, a positive integer as its arguments. If the givenn
is larger than the number of nodes in the list, returnnull
.
I've written an implementation that determines the solution in O(n)
time complexity (worst case).
- JavaScript