class Solution {
public:
int removeDuplicates(int A[], int n) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
if (n == 0) return 0;
int i = 0;
for (int j = 0; j < n; j++) {
if (A[i] != A[j]) {
A[++i] = A[j];
}
}
return i + 1;
}
};
Small Case: 4ms
Large Case: 60ms
Time: O(n)
Space: O(1)