Insert a node at the head of a linked list Hackkerank

 static SinglyLinkedListNode insertNodeAtHead(SinglyLinkedListNode llist, int data) {

        SinglyLinkedListNode temp=llist;
        SinglyLinkedListNode newNode =new SinglyLinkedListNode(data);
        llist=newNode;
        newNode.next=temp;
        return llist;
    }

Comments

Popular posts from this blog

Java Date And Time HackerRank

Recursive Sequence Geeks For Geeks Problem Of The Day 12-02-2024

Minimum Indices HackerEarth