Hackerrank 30 days of code Java Solution: Day 15: Linked List

The next problem is based on Data Structure “Linked List”. It is a data structure having a collection of elements where every element has a reference pointing to the next element in the collection.Each element in linked list is called a node which has commonly two parts; the data part and the reference part which holds the link to the other node.

Task

Complete the insert function in your editor so that it creates a new Node (pass  as the Node constructor argument) and inserts it at the tail of the linked list referenced by the  parameter. Once the new node is added, return the reference to the  node.

Sample Input

Sample Output

So here  lies your Solution .

Thanks for the visit checkout the day 16 tutorial as well.. 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *