Insert a node at the head of a linked list, is a HackerRank problem from Linked Lists subdomain. In this post we will see how we can solve this challenge in Python

Problem Description

You’re given the pointer to the head node of a linked list and an integer to add to the list. Create a new node with the given integer, insert this node at the head of the linked list and return the new head node. The head pointer given may be null meaning that the initial list is empty.

Input Form ....

You can find the full details of the problem Insert a node at the head of a linked list at HackerRank

Solution: Please check the insert-a-node-at-the-head-of-a-linked-list.py snippet for the solution.

This solution originally posted at: Github by @srgnk