We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Hiring developers?
  1. Prepare
  2. Tutorials
  3. 30 Days of Code
  4. Day 15: Linked List
  5. Discussions

Day 15: Linked List

Problem
Submissions
Leaderboard
Discussions
Editorial
Tutorial

Sort 681 Discussions, By:

recency

Please Login in order to post a comment

  • lucasopoka
    4 days ago+ 0 comments

    Python

        def insert(self,head,data): 
            nd = Node(data)
            nth = head
            if head is None:
                head = nd
            else:
                while nth.next is not None:
                    nth = nth.next
                nth.next = nd
            return head
    
    0|
    Permalink
  • elsebaey95
    2 weeks ago+ 0 comments

    c++

          Node* insert(Node *head,int data)
          {
            //Complete this method
            if(head==NULL){
               Node* g=new Node(data);
               return g;
            }
            head->next=insert(head->next,data);
            return head;
          }
    
    0|
    Permalink
  • elsebaey95
    2 weeks ago+ 0 comments

    c

    Node* insert(Node *head,int data)
    {
        //Complete this function
         if(head==NULL){
            Node* g=(Node*)malloc(sizeof(Node));
            g->data=data;
            g->next=NULL;
            return g;
         }
         head->next=insert(head->next,data);
         return head;
    }
    
    0|
    Permalink
  • ranggakd
    3 weeks ago+ 0 comments

    SEARCH THE ANSWER HERE

    0|
    Permalink
  • ehabmagdy
    4 weeks ago+ 0 comments

    C solution

    Node *temp = (Node*)malloc(sizeof(Node));
    temp->data = data;
    temp->next = NULL;
    if(NULL == head){
        head = temp;
    }
    else{
        Node *ptr = head;
        while(ptr->next){
            ptr = ptr->next;
        }
        ptr->next = temp;
    }
    return head;
    
    0|
    Permalink
Load more conversations

Need Help?


View tutorial
View editorial
View top submissions
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy