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
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. Prepare
  2. Data Structures
  3. Linked Lists
  4. Insert a node at the head of a linked list
  5. Discussions

Insert a node at the head of a linked list

Problem
Submissions
Leaderboard
Discussions
Editorial

Sort 800 Discussions, By:

votes

Please Login in order to post a comment

  • GustavK
    4 years ago+ 23 comments

    Uneditable code in C# doesn't compile as it is.

    solution.cs(78,36): error CS0214: Pointers and fixed size buffers may only be used in an unsafe context solution.cs(78,36): error CS0193: The * or -> operator must be applied to a pointer Compilation failed: 2 error(s), 0 warnings

    93|
    Permalink
    View more Comments..
  • giulianopietoso
    4 years ago+ 20 comments

    Yep, the "IDE" is bugged. All codes are correct but it keeps saying:

    Your Output (stdout) Right Answer!

    And doesn't pass.

    65|
    Permalink
    View more Comments..
  • bs436
    4 years ago+ 17 comments

    solution.c: In function ‘main’: solution.c:111:36: error: ‘SinglyLinkedList {aka struct SinglyLinkedList}’ has no member named ‘headhead’; did you mean ‘head’? free_singly_linked_list(llist->headhead);

    There is a typo in the default code and I cant edit it

    21|
    Permalink
    View more Comments..
  • esHack
    7 years ago+ 4 comments

    Node Insert(Node head,int x) {

    Node node1 =new Node();
    
    node1.data = x;
    node1.next= head;
    return node1;
    

    }

    17|
    Permalink
    View more Comments..
  • skkaushik5128
    4 years ago+ 0 comments

    Hi,

    My code is in C#:

    SinglyLinkedList list = new SinglyLinkedList(); SinglyLinkedListNode node = llist;

        if(node == null)
        {
            node.data = data;
            node.next = null;    
            list.head = node;
        }
        else
        {
            node.data = data;
            node.next = llist;
            list.head = node;
        }
        return list.head;
    

    I am facing compile time issue as below:

    Compile Message

    solution.cs(93,36): error CS0214: Pointers and fixed size buffers may only be used in an unsafe context solution.cs(93,36): error CS0193: The * or -> operator must be applied to a pointer Compilation failed: 2 error(s), 0 warnings Exit Status

    255

    Please help.

    14|
    Permalink
Load more conversations

Need Help?


View editorial
View top submissions
  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature