similar to implemented solution with some missing logic
🤔What Did I Struggle With?
forgot to delete / free up memory for removed nodes
💡 Explanation of Solution
- create a dummy node and initialize its values to 0, point its next to head
- create another list node curr that is equal to the dummy node
- traverse the list while curr->next is not null
- if curr->next is equal to val
- create a temp node that is equal to curr->next
- make curr->next equal to curr->next->next
- delete temp
- else move to the next node
- get rid of the dummy node by creating a newHead node equal to dummy->next
- delete dummy
- return the newHead