Sort by

recency

|

716 Discussions

|

  • + 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;
          }
    
  • + 0 comments
    public static  Node insert(Node head,int data)
    	{
          
        Node newNode = new Node(data);
      
        if (head == null)
        {
            return newNode;
        }
    
        Node current = head;
        while (current.next != null)
        {
            current = current.next;
        }
    
        current.next = newNode;
         return head;
        }
    
  • + 0 comments
    public static  Node insert(Node head,int data) {
            //Complete this method
            
            Node current = head;
            if (head == null)
                head = new Node(data);
            else{
                while(current.next != null){
                    current = current.next;
                }
                    current.next = new Node(data);
            }
            return head;
        }
    
  • + 0 comments

    Why do the typescript problems never have the implementations? There's no node class

  • + 0 comments

    I kinda hacked it I guess, by using self field. Though it happened cause I didn't watch the video and didn't understand what was required of me and why my intuitional approach yielded result reversal to demanded

    def insert(self, head, data):
            node = Node(data)
            if head is None:
                self.prev = node
                return node
            else:
                self.prev.next = node
                self.prev = node
            return head`