data-structures · intermediate · ~15 min
Mutating a linked list while preserving its head.
Given the same node_t definition, implement node_t *insert(node_t *head, int value) that appends a new node and returns the (possibly new) head. If head is NULL the new node becomes head.
#include <stdlib.h>
node_t *insert(node_t *head, int value) {
/* TODO */
return head;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.