【leetcode❤python】26. Remove Duplicates from Sorted Array
#-*- 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的更多相关文章
- 【leetcode❤python】83. Remove Duplicates from Sorted List
#-*- coding: UTF-8 -*- # Definition for singly-linked list.# class ListNode(object):# def __init ...
- leetCode练题——26. Remove Duplicates from Sorted Array
1.题目 26. Remove Duplicates from Sorted Array--Easy Given a sorted array nums, remove the duplicates ...
- 【leetcode】 26. Remove Duplicates from Sorted Array
@requires_authorization @author johnsondu @create_time 2015.7.22 18:58 @url [remove dublicates from ...
- 【LeetCode】26. Remove Duplicates from Sorted Array 解题报告(Python&C++&Java)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 双指针 日期 [LeetCode] https:// ...
- 【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 ...
- 【一天一道LeetCode】#26. Remove Duplicates from Sorted Array
一天一道LeetCode系列 (一)题目 Given a sorted array, remove the duplicates in place such that each element app ...
- LeetCode记录之26——Remove Duplicates from Sorted Array
国外的表达思维跟咱们有很大差别,做这道题的时候很明显.简单说本题就是让你把有序数组中的重复项给换成正常有序的.比如 1 2 2 3换成 1 2 3 3,根本不需要考虑重复的怎么办,怎么删除重复项等等. ...
- 【一天一道LeetCode】#80. Remove Duplicates from Sorted Array II
一天一道LeetCode 本系列文章已全部上传至我的github,地址:ZeeCoder's Github 欢迎大家关注我的新浪微博,我的新浪微博 欢迎转载,转载请注明出处 (一)题目 Follow ...
- 26. Remove Duplicates from Sorted Array【easy】
26. Remove Duplicates from Sorted Array[easy] Given a sorted array, remove the duplicates in place s ...
随机推荐
- JQ 获取单选按钮选中的值
==========================html 代码 <input type="radio" style="float: left " on ...
- 夺命雷公狗—angularjs—11—service的基本概念
我们先来研究下service里面的四大服务.. value 变量 constant 常量 factory 工厂模式 service 服务 <!DOCTYPE html> <ht ...
- 夺命雷公狗---2016-linux---2之软件实现远程登录
废话不多说,操作方法如下所示:
- [tp3.2.1]sql查询语句(一)
基本查询方式 字符串条件查询, 索引数组条件查询 对象条件查询 SQL语句大小写是一样的,但是,执行的时候有一个小写到大写的转换,所以最好写大写 $condition=new ...
- sql语句删除数据表重复字段的方法
大家都可能遇到字段重复的情况,网上很多人在找方法,也给出了一些方法,但是有的方法是误导大家,铁牛写出以下方法,方便大家使用 1.通过group by把重复的字段筛选出来,并建立临时表tmp 1 cre ...
- TP主从服务器配置
在config.php文件中,设置‘DB_DEPLOY_TYPE’=>1,‘DB_HOST’=>‘localhost,192.168.0.1,192.168.0.23’,各个主机之间用逗号 ...
- THE HANDLER_READ_* STATUS VARIABLES
Because I do a lot of Performance Tuning gigs I get often in contact with these status variables. In ...
- 为什么drop table的时候要在checking permissions花很长时间?
昨天,我drop一个表的时候在checking permissions花了20s+,这个时间花在哪里了呢?经常查找发现我的配置文件innodb_file_per_table=1的,innodb需要遍历 ...
- docker RESTful API
https://docs.docker.com/engine/reference/api/docker_remote_api/
- 【python cookbook】【字符串与文本】14.字符串连接及合并
问题:将许多小字符串合并成一个大的字符串 解决方案: 1.针对少数量的字符串:+ 2.针对大量的字符串对象的连接,更高效的方法:join() 3.更加复杂的字符串:format() >>& ...