Sort by

recency

|

820 Discussions

|

  • + 0 comments
    def deleteNode(llist, position):
        if position == 0:
            return llist.next
        
        cur = llist
        
        while position > 1:
            cur = cur.next
            position -= 1
        cur.next = cur.next.next
        return llist
    
  • + 0 comments

    js solution function deleteNode(llist, position) { // Write your code here
    let currentNode = llist;

    if (position===0) {
    
         llist=llist.next;
         return 
    
    };
    
    for (let i = 0; i < position - 1; i++) {
    
        currentNode = currentNode.next;
    
    }
    

    currentNode.next=currentNode.next.next

    return llist

    }

  • + 0 comments

    Here is my c++ solution, you can have the video explanation here : https://youtu.be/EjWw69vLVYo

    SinglyLinkedListNode* deleteNode(SinglyLinkedListNode* llist, int position) {
        if(position == 0) return llist->next;
        SinglyLinkedListNode* curr = llist;
        while(position - 1) {
            curr = curr -> next;
            position--;
        }
        curr->next = curr->next->next;
        return llist;
    }
    
  • + 0 comments

    my c prgramming code

    SinglyLinkedListNode* deleteNode(SinglyLinkedListNode* llist, int position) { SinglyLinkedListNode* temp1=llist; SinglyLinkedListNode* prev; if(llist==NULL){ return llist; } for(int i=0;inext; }prev->next=temp1->next; return llist; }

  • + 0 comments

    hello Guys,I faced issue as compilation error is there anyone who faced that issue and how can i solve it