prev
as the sentinel node and curr
as the head of the list.curr
is not null.curr.val
equals val
, set prev.next
to curr.next
to remove curr
from the list.curr.val
does not equal val
, set prev
to curr
to move the prev
pointer forward.curr
to the next node in the list.sentinel.next
, which is the new head of the modified list.