本文主要是介绍[leetcode]Remove Duplicates from Sorted Array,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
class Solution {
public:int removeDuplicates(int A[], int n) {// Start typing your C/C++ solution below// DO NOT write int main() functionint len = 0;for(int i = 1; i < n; i++){if(A[i] == A[i-1]){len++;}else{A[i-len] = A[i];}}return n-len;}
};
这篇关于[leetcode]Remove Duplicates from Sorted Array的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!