Insert a Node at the Head of a Linked ListEasy
This challenge is part of a tutorial track by MyCodeSchool and is accompanied by a video lesson.
Given a pointer to the head of a linked list, insert a new node before the head. The \(next\) value in the new node should point to \(head\) and the \(data\) value should be replaced with a given value. Return a reference to the new head of the list. The head pointer given may be null meaning that the initial list is empty.