Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save toliuweijing/6147739 to your computer and use it in GitHub Desktop.
Save toliuweijing/6147739 to your computer and use it in GitHub Desktop.
class Solution {
public:
int removeDuplicates(int A[], int n) {
int len = 0;
for (int i = 0 ; i < n ; ++i) {
if (len > 0 && A[len-1] == A[i]) continue;
A[len++] = A[i];
}
return len;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment