Delete a Linked List Node by Value
hardQuestion 473Read an integer n, then n values, and build a singly linked list holding them in the order they were read. Then read one more integer: the target.
Print the list, delete the FIRST node whose value equals the target — unlink it and free() that one node — and print the list again. Between the two lists print one status line: Removed TARGET if a node was deleted, or Not found TARGET if no node held that value.
For the input:
4 4 8 15 8 8
the program prints exactly the output shown in Expected Output.
Only the first match goes. Deleting the head must also work. List format: the label, a colon, then for EVERY node a space, the value, a space and ->, and a space and NULL after the last node.
Free the memory you allocate before the program ends — this question checks for memory leaks.
Expected output
Before: 4 -> 8 -> 15 -> 8 -> NULL Removed 8 After: 4 -> 15 -> 8 -> NULL
= newline. The output ends with a newline, so print one after the last line.
Your output
Run your code to see the output here...