• + 0 comments

    c++ soln

    SinglyLinkedListNode* deleteNode(SinglyLinkedListNode* llist, int position) { SinglyLinkedListNode* temp=llist;

    if(position==0){
        temp=llist->next;
        return temp;
        }
    else{
        while(position>1){
            position--;
            temp=temp->next;
        }
        SinglyLinkedListNode* to_remove=temp->next;
        temp->next=temp->next->next;
        delete to_remove;
    
    }
    return llist;
    

    }