Generation solution

It's the same idea with "Remove Duplicates from Sorted Array", can be extended to more general problem.