2017년 12월 23일 토요일

[C++] HackerRank Day15 Solution

/*
https://www.hackerrank.com/challenges/30-linked-list/problem

Insert function in Linked list.

*/




      Node* insert(Node *head,int data)
      {
          Node *newNode = new Node(data);
           
          if(head == NULL) {
              head = newNode;
              return head;
          }
         
          Node *cur = head;
          while(cur->next != NULL) {
              cur=cur->next;
          } 
          cur->next = newNode;

          return head;
      }

댓글 없음:

댓글 쓰기