@liyangguang1988 Good solution,and I wanna share my solution.

description: define a number that is greater than the maximum of the array,just like int max=nums[nums.length-1]+1, then replace the repeated numbers with the max number,then sort the array,just return non repetition length we calculate.

Remove Duplicates from Sorted Array