#-*- coding: UTF-8 -*-
class Solution(object):
    def removeDuplicates(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        if len(nums)<=1:return len(nums)
        pre=0;next=1
        while True:
            if nums[next]==nums[pre]:
                del nums[next]
            else:
                pre=next
                next+=1
            if next>=len(nums):break
            
        return len(nums)    
        
#        sorted(set(nums),key=nums.index)
#        print nums
sol=Solution()
print sol.removeDuplicates([1,1,2,2,4,4,5,5])

【leetcode❤python】26. Remove Duplicates from Sorted Array的更多相关文章

  1. 【leetcode❤python】83. Remove Duplicates from Sorted List

    #-*- coding: UTF-8 -*- # Definition for singly-linked list.# class ListNode(object):#     def __init ...

  2. leetCode练题——26. Remove Duplicates from Sorted Array

    1.题目 26. Remove Duplicates from Sorted Array--Easy Given a sorted array nums, remove the duplicates  ...

  3. 【leetcode】 26. Remove Duplicates from Sorted Array

    @requires_authorization @author johnsondu @create_time 2015.7.22 18:58 @url [remove dublicates from ...

  4. 【LeetCode】26. Remove Duplicates from Sorted Array 解题报告(Python&C++&Java)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 双指针 日期 [LeetCode] https:// ...

  5. 【LeetCode】26. Remove Duplicates from Sorted Array

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

  6. 【一天一道LeetCode】#26. Remove Duplicates from Sorted Array

    一天一道LeetCode系列 (一)题目 Given a sorted array, remove the duplicates in place such that each element app ...

  7. LeetCode记录之26——Remove Duplicates from Sorted Array

    国外的表达思维跟咱们有很大差别,做这道题的时候很明显.简单说本题就是让你把有序数组中的重复项给换成正常有序的.比如 1 2 2 3换成 1 2 3 3,根本不需要考虑重复的怎么办,怎么删除重复项等等. ...

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

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

  9. 26. Remove Duplicates from Sorted Array【easy】

    26. Remove Duplicates from Sorted Array[easy] Given a sorted array, remove the duplicates in place s ...

随机推荐

  1. zw版_Halcon图像交换、数据格式、以及超级简单实用的DIY全内存计算.TXT

    zw版_Halcon图像交换.数据格式.以及超级简单实用的DIY全内存计算.TXT Halcon由于效率和其他原因,内部图像采用了很多自有格式,提高运行速度,但在数据交换方面非常麻烦. 特别是基于co ...

  2. 【ruby】安装Ruby

    系统需求 首先确定操作系统环境,不建议在 Windows 上面搞,所以你需要用: Mac OS X 任意 Linux 发行版本 配置系统包 $ sudo apt-get install -y buil ...

  3. ASP.NET 中通过Form身份验证 来模拟Windows 域服务身份验证的方法

    This step-by-step article demonstrates how an ASP.NET   application can use Forms authentication to ...

  4. 创建数据库和表的SQL语句【转】

    创建数据库和表的SQL语句 转至http://www.cnblogs.com/philanthr/archive/2011/08/09/2132398.html 创建数据库的SQL语句: 1 crea ...

  5. sql数据库(资料库)的基本操作

    1 Character Set与Collation 任何资讯技术在处理资料的时候,如果只是单纯的数值和运算,那就不会有太复杂的问题:如果处理的资料是文字的话,就会面临世界上各种不同语言的问题.以资料库 ...

  6. Delphi Xe2 后的版本如何让Delphi程序启动自动“以管理员身份运行"

    由于Vista以后win中加入的UAC安全机制,采用Delphi开发的程序如果不右键点击“以管理员身份运行”,则会报错. 在XE2以上的Delphi版本处理这个问题已经非常简单了. 右建点击工程,选择 ...

  7. 在CentOS 6 32/64 上安装 PPTP 方式 VPN 服务

    网上有很多步骤, 讲了很多步骤,废话, 其实不如直接看代码, 而且也能直接运行,快速安装: rm -f /etc/pptpd.conf rm -f /etc/ppp arch=`uname -m` # ...

  8. php的ssh2扩展安装

    折腾半天,结论如下: 1.先需要openssl 用which openssl看是否已安装 2.然后libssh2 用rpm -ql libssh2查看 3.下载源码的shh2x.x.x.tgz的包 4 ...

  9. sql server 关联更新

    update a set a.name1 = b.name1, a.name2=b.name2from 表A a, 表B b where a.id=b.id

  10. Java使用基本字节流OutputStream的四种方式对于数据复制(文本,音视频,图像等数据)

    //package 字符缓冲流bufferreaderDemo; import java.io.BufferedOutputStream; import java.io.FileInputStream ...