Skip to content

Latest commit

 

History

History
16 lines (11 loc) · 685 Bytes

File metadata and controls

16 lines (11 loc) · 685 Bytes

N-th Element of a Linked List

Problem Description

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 given n is larger than the number of nodes in the list, return null.

Solution

I've written an implementation that determines the solution in O(n) time complexity (worst case).