Insert a node at the head of a linked list HackerRank Solution


Insert a node at the head of a linked list HackerRank Solution
Source : https://www.hackerrank.com/challenges/insert-a-node-at-the-head-of-a-linked-list



Source : https://www.hackerrank.com/challenges/insert-a-node-at-the-head-of-a-linked-list


Solution


// Karthikalapati.blogspot.com
/*
Insert Node at the beginning of a linked list
Node is defined as
class Node {
int data;
Node next;
}
*/
Node Insert(Node head, int x) {
Node n = new Node();
n.data = x;
n.next = head;
return n;
}

7 comments:

  1. It is fine, nonetheless evaluate the information and facts around this correct. Easy Drawing

    ReplyDelete
  2. I read this article. I think You put a lot of effort to create this article. I appreciate your work. ibrahimmuratgündüz

    ReplyDelete
  3. Acknowledges for penmanship such a worthy column, I stumbled beside your blog besides predict a handful advise. I want your tone of manuscript... ibrahim murat gündüz haber

    ReplyDelete
  4. I have a similar interest this is my page read everything carefully and let me know what you think. h1000 powder

    ReplyDelete
  5. I invite you to the page where you can read with interesting information on similar topics. Freska skin lounge

    ReplyDelete