before_head
and after_head
to serve as the heads of the two new linked lists.before
and after
to point to the current last node of the before
and after
lists, respectively.x
, append it to the before
list.x
, append it to the after
list.before
list to the after
list by setting before.next
to after_head.next
.before_head.next
as the new head of the partitioned linked list.