• + 0 comments

    I was hoping for a golang option. C++ is good enough I suppose...

    Node* insert(Node *head,int data)
          {
              //Complete this method          
              Node *dummyNode = new Node(0);
              dummyNode->next = head;
              Node *newNode = new Node(data);
              Node *current = dummyNode;
              
              while (current->next != NULL) {
                current = current->next;
              }
              current->next = newNode;
              return dummyNode->next;
          }