Remove Duplicates from Sorted Array @leetcode
http://oj.leetcode.com/problems/remove-duplicates-from-sorted-array/
1 class Solution { 2 public: 3 int removeDuplicates(int A[], int n) { 4 int tmp = 0; 5 for(int i = 1;i < n;++i){ 6 if(A[i] == A[i-1]) ++tmp; 7 A[i-tmp] = A[i]; 8 } 9 return n - tmp; 10 } 11 };
!亦是特征向量。直接使用-用后即忘版。