exercises/ex13/list_errors_soln.c
int remove_by_value(Node **list, int val) {
    Node *node = *list;

    if (node == NULL) {
        return 0;
    }

    if (node->val == val) {
        pop(list);
        return 1;
    }

    for(; node->next != NULL; node = node->next) {
        if (node->next->val == val) {
            Node *victim = node->next;
            node->next = victim->next;
            free(victim);
            return 1;
        }
    }
    return 0;
}
/* Removes the first element with the given value
*
* Frees the removed node.
*
* list: pointer to pointer to Node
* val: value to remove
*
* returns: number of nodes removed
*/
Removes the first element with the given value
Frees the removed node.



number of nodes removed
Removes the first element with the given value Frees the removed node . number of nodes removed
int remove_by_value(Node **list, int val) {
    Node *node = *list;
    if (node == NULL) {
        return 0;
    }
    if (node->val == val) {
        pop(list);
        return 1;
    }
    for(; node->next != NULL; node = node->next) {
        if (node->next->val == val) {
            Node *victim = node->next;
            node->next = victim->next;
            free(victim);
            return 1;
        }
    }
    return 0;
}
int remove_by_value ( Node * * list , int val ) { Node * node = * list ; if ( node == NULL ) { return 0 ; } if ( node -> val == val ) { pop ( list ) ; return 1 ; } for ( ; node -> next != NULL ; node = node -> next ) { if ( node -> next -> val == val ) { Node * victim = node -> next ; node -> next = victim -> next ; free ( victim ) ; return 1 ; } } return 0 ; }
Removes the first element with the given value
Frees the removed node.
Removes the first element with the given value Frees the removed node .