博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
leetcode 36: Remove Duplicates from Sorted Array II
阅读量:7012 次
发布时间:2019-06-28

本文共 573 字,大约阅读时间需要 1 分钟。

Follow up for "Remove Duplicates":
What if duplicates are allowed at most twice?

For example,

Given sorted array A = [1,1,1,2,2,3],

Your function should return length = 5, and A is now [1,1,2,2,3].

class Solution {public:    int removeDuplicates(int A[], int n) {        // Start typing your C/C++ solution below        // DO NOT write int main() function                if(n<=1) return n;                int i=0;        int j=1;        bool flag = false;        int temp = A[i];                while( j

转载于:https://www.cnblogs.com/xishibean/archive/2013/01/15/2951386.html

你可能感兴趣的文章