Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.

Do not allocate extra space for another array, you must do this in place with constant memory.

For example,
Given input array A = [1,1,2],

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

     int removeDuplicates(int A[], int n) {
if(n == )
return ;
if(n == )
return ;
int end = ;
for(int i = ; i < n; i ++) {
if(A[i] != A[end]){
end ++;
A[end] = A[i];
}
}
return end + ;
}

Remove Duplicates from Sorted Array [LeetCode]的更多相关文章

  1. Remove Duplicates From Sorted Array leetcode java

    算法描述: Given a sorted array, remove the duplicates in place such that each element appear only once a ...

  2. Remove Duplicates From Sorted Array

    Remove Duplicates from Sorted Array LeetCode OJ Given a sorted array, remove the duplicates in place ...

  3. [LeetCode] Remove Duplicates from Sorted Array II 有序数组中去除重复项之二

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

  4. [LeetCode] Remove Duplicates from Sorted Array 有序数组中去除重复项

    Given a sorted array, remove the duplicates in place such that each element appear only once and ret ...

  5. LeetCode:Remove Duplicates from Sorted Array I II

    LeetCode:Remove Duplicates from Sorted Array Given a sorted array, remove the duplicates in place su ...

  6. [Leetcode][Python]26: Remove Duplicates from Sorted Array

    # -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com' 26: Remove Duplicates from Sorted Array ...

  7. 【一天一道LeetCode】#80. Remove Duplicates from Sorted Array II

    一天一道LeetCode 本系列文章已全部上传至我的github,地址:ZeeCoder's Github 欢迎大家关注我的新浪微博,我的新浪微博 欢迎转载,转载请注明出处 (一)题目 Follow ...

  8. LeetCode 80 Remove Duplicates from Sorted Array II [Array/auto] <c++>

    LeetCode 80 Remove Duplicates from Sorted Array II [Array/auto] <c++> 给出排序好的一维数组,如果一个元素重复出现的次数 ...

  9. LeetCode 26 Remove Duplicates from Sorted Array [Array/std::distance/std::unique] <c++>

    LeetCode 26 Remove Duplicates from Sorted Array [Array/std::distance/std::unique] <c++> 给出排序好的 ...

随机推荐

  1. Installing Chocolatey

    https://chocolatey.org/install To install chocolatey now, open an administrative command prompt and ...

  2. PHPwebshell分析

    这几天已知在做webshell的检测,JSP的不说了,特征检测起来很好匹配到,而且全是一家亲,互相模仿的居多. 今天看了一篇文章,看到14年蘑菇的webshell的后门然后很不错. ========= ...

  3. 【转】Haproxy安装及配置

    1.安装 # wget http://haproxy.1wt.eu/download/1.3/src/haproxy-1.3.20.tar.gz # tar zcvf haproxy-1.3.20.t ...

  4. HDU 5826 physics(物理)

     physics(物理) Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)   D ...

  5. yii-mail yii 发送邮件

    参考网址:http://shoukii0721.iteye.com/blog/1576225 有很多时候我们需要给用户发送邮件,作留言,或者是激活邮件.等用途. 需要注意的是,设置发送的邮件得有SMT ...

  6. vector的插入、lower_bound、upper_bound、equal_range实例

    对于这几个函数的一些实例以便于理解: #include <cstdlib> #include <cstdio> #include <cstring> #includ ...

  7. springmvc:frameServletBean

    1.httpservlerBean 主要初始化web.xml的init-param参数 2.frameWorkServlet 该类作用 1.applicationConetxt用于配置整体 webap ...

  8. CentOS的包/库的找的地方

    1. http://pkgs.org/ 在这个网站里面 搜索相应的 包名,看能不能找到. 2. http://rpm.pbone.net/ 在这个网站里面 搜索相应的 包名,看能不能找到. 3.

  9. 使用myeclipse建立maven项目(重要)

    maven是管理项目的,myeclipse是编写代码的.第一次写项目都要配置好多东西,很麻烦,now 来看看怎样新建一个maven项目. 工具/原料   myeclipse maven 方法/步骤   ...

  10. Docker-网络基础配置

    从外部访问容器 指定容器端口随机映射主机端口 [root@wls12c /]$ docker run -p -d --name web tomcat /bin/bash -c /root/apache ...