← Return

Get Node ValueEasy

This challenge is part of a tutorial track by MyCodeSchool

Given a pointer to the head of a linked list and a specific position, determine the data value at that position. Count backwards from the tail node. The tail is at postion 0, its parent is at 1 and so on.

Example

\(head\) refers to \(3 \to 2 \to 1 \to 0 \to NULL\)

\(positionFromTail = 2\)

Each of the data values matches its distance from the tail. The value \(2\) is at the desired position.