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
  • Apply
  • Hiring developers?
  1. Prepare
  2. Data Structures
  3. Linked Lists
  4. Insert a node at a specific position in a linked list
  5. Discussions

Insert a node at a specific position in a linked list

Problem
Submissions
Leaderboard
Discussions
Editorial

Sort 1453 Discussions, By:

recency

Please Login in order to post a comment

  • suvinkumarparam1
    16 hours ago+ 0 comments

    public static SinglyLinkedListNode insertNodeAtPosition(SinglyLinkedListNode llist, int data, int position) { SinglyLinkedListNode newNode = new SinglyLinkedListNode(data);

        if (position == 0) {
            newNode.next = llist;
            return newNode;
        } else {
            SinglyLinkedListNode temp = llist;
            for (int i = 1; i < position; i++) {
                temp = temp.next;
            }
            newNode.next = temp.next;
            temp.next = newNode;
            return llist;
        }
    }
    
    0|
    Permalink
  • dream101221
    1 week ago+ 0 comments

    Here is the solution of Insert a node at a specific position in a linked list Click Here

    0|
    Permalink
  • anamch167447
    1 week ago+ 0 comments

    Great stuff, i really like your way of explaining. Now could you please have a look on my site and let me know about it.

    0|
    Permalink
  • tuph4031
    2 weeks ago+ 1 comment

    My solution in Java by two ways: iteration and recursion https://github.com/tuphan22028238/DSA/tree/main/BTLinkedList

    0|
    Permalink
  • sabirsonia98
    4 weeks ago+ 0 comments

    Certainly, I'd appreciate it if you could share your recommendations for the top websites where I can find the highest-quality gold available in the market.

    0|
    Permalink
Load more conversations

Need Help?


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