Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //https://www.hackerrank.com/challenges/30-linked-list/problem
- public static Node insert(Node head,int data)
- {
- //Complete this method
- if(head == null){
- head = new Node(data);
- return head;
- }
- Node n = head;
- while(n.next != null){
- n = n.next;
- }
- n.next = new Node(data);
- return head;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement