RemoveDuplicatesFromSortedListII-refactor the code