問題描寫:
Givena sorted array, remove the duplicates in place such that each element appearonly once and return the new length.
Do not allocate extra space for another array, youmust do this in place with constant memory.
For example,
Given input array A = [1,1,2],
Your function should return length = 2, and A isnow [1,2].
問題分析:使用1個count統計不同的元素個數,然后注意A[count] = A[i]來消除重復元素便可
代碼: