• + 0 comments

    here's my solution in C language:

    SinglyLinkedListNode* deleteNode(SinglyLinkedListNode* llist, int position) { SinglyLinkedListNode *fnnode = llist; if(llist == NULL || position <= -1){ return llist; } else if (position == 0){ llist = llist->next; free(fnnode); return llist; } else{ int counter = 0; while(fnnode != NULL && counter < position - 1){ fnnode = fnnode -> next; counter++; } if(fnnode != NULL && fnnode->next != NULL){ SinglyLinkedListNode *delf = fnnode -> next; fnnode -> next = fnnode->next->next; free(delf); } } return llist; }