#-*- 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. EBS 密码相关

    SELECT usr.user_name, apps.cux_fnd_web_sec.decrypt ((SELECT (SELECT apps.cux_fnd_web_sec.decrypt (fn ...

  2. SQL语句:find_in_set的使用方法

    如果我们有一张表: 里面有的信息如下: 我们需要查找出friends字段里面包含11的值. 我们传统的方法是: %"; 但是这样查到的结果2条的,不大符合我们的需求,如下所示: 我们只想查找 ...

  3. yii2获取登陆的用户名

    yii2获取登陆的用户名: yii::$app->user->identity->username; 判断用户名是否登陆 if(Yii::$app->user->isGu ...

  4. linux设备驱动归纳总结(四):1.进程管理的相关概念【转】

    本文转载自;http://blog.chinaunix.net/uid-25014876-id-64866.html linux设备驱动归纳总结(四):1.进程管理的相关概念 xxxxxxxxxxxx ...

  5. python DB.fetchall()--获取数据库所有记录列表

    查询到的数据格式为列表: 多个元素的列表:

  6. TI BLE CC2541的I2C主模式

    由于要写TM1680, 写命令跟写数据, 所以需要使用CC2541的I2C, 2541是有硬件I2C的. tm1680.c: #include "tm1680.h" //TM168 ...

  7. linux用户栈内核栈的设置---进程的创建: fork/execve【转】

    转自:http://blog.csdn.net/u011279649/article/details/18795547 版权声明:本文为博主原创文章,未经博主允许不得转载. 目录(?)[-] 应用层怎 ...

  8. java中OutputStream字节流与字符流InputStreamReader 每一种基本IO流BufferedOutputStream,FileInputStream,FileOutputStream,BufferedInputStream,BufferedReader,BufferedWriter,FileInputStream,FileReader,FileWriter,InputStr

    BufferedOutputStream,FileInputStream,FileOutputStream,BufferedInputStream,BufferedReader,BufferedWri ...

  9. VirtualBox启动虚拟机报错0x80004005

    Unable to load R3 module C:\Program Files\Oracle\VirtualBox/VBoxDD.DLL (VBoxDD): GetLastError=1790 ( ...

  10. 10、会话管理/编程实战分析/Jsp

    1 会话管理回顾 会话管理 1)会话管理: 管理浏览器和服务器之间的会话过程中产生的会话数据 2)Cookie技术: 会话数据保存在浏览器客户端. Cookie核心的API: 2.1 在服务器端创建C ...