Solved linked list partitioning problem