code for "Partition List" (Singly-linked list)