Solution for remove duplicates II