Advertisement
minnera

#30daysofcode #day15

Oct 19th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.37 KB | None | 0 0
  1. //https://www.hackerrank.com/challenges/30-linked-list/problem
  2.  
  3.     public static  Node insert(Node head,int data)
  4.     {
  5.       //Complete this method
  6.       if(head == null){
  7.         head = new Node(data);
  8.         return head;
  9.       }
  10.       Node n = head;
  11.       while(n.next != null){
  12.         n = n.next;
  13.       }
  14.       n.next = new Node(data);
  15.       return head;
  16.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement