mycode  76.39%

class Solution(object):
def containsDuplicate(self, nums):
"""
:type nums: List[int]
:rtype: bool
"""
if len(nums) == 0 or len(nums) == 1:
return False
return not (len(set(nums)) == len(nums))

参考

最快:

class Solution(object):
def containsDuplicate(self, nums):
"""
:type nums: List[int]
:rtype: bool
"""
hasht = {}
for num in nums:
if num not in hasht:
hasht[num] = True
else:
return True
return False

leetcode-easy-array-217. Contains Duplicate的更多相关文章

  1. [LeetCode&Python] Problem 217. Contains Duplicate

    Given an array of integers, find if the array contains any duplicates. Your function should return t ...

  2. [Array]217.Contains Duplicate

    Given an array of integers, find if the array contains any duplicates. Your function should return t ...

  3. 【leetcode❤python】217. Contains Duplicate

    #-*- coding: UTF-8 -*- class Solution(object):    def containsDuplicate(self, nums):        numsdic= ...

  4. leetcode 217. Contains Duplicate 287. Find the Duplicate Number 442. Find All Duplicates in an Array 448. Find All Numbers Disappeared in an Array

    后面3个题都是限制在1-n的,所有可以不先排序,可以利用巧方法做.最后两个题几乎一模一样. 217. Contains Duplicate class Solution { public: bool ...

  5. 217. Contains Duplicate【easy】

    217. Contains Duplicate[easy] Given an array of integers, find if the array contains any duplicates. ...

  6. 25. leetcode 217. Contains Duplicate

    217. Contains Duplicate Given an array of integers, find if the array contains any duplicates. Your ...

  7. LN : leetcode 217 Contains Duplicate

    lc 217 Contains Duplicate 217 Contains Duplicate Given an array of integers, find if the array conta ...

  8. LeetCode Javascript实现 169. Majority Element 217. Contains Duplicate(两个对象比较是否相等时,如果都指向同一个对象,a==b才是true)350. Intersection of Two Arrays II

    169. Majority Element /** * @param {number[]} nums * @return {number} */ var majorityElement = funct ...

  9. 217. Contains Duplicate(C++)

    217. Contains Duplicate Given an array of integers, find if the array contains any duplicates. Your ...

  10. LeetCode(220) Contains Duplicate III

    题目 Given an array of integers, find out whether there are two distinct indices i and j in the array ...

随机推荐

  1. Jmeter读取CSV文件,请求参数乱码

    Jmeter读取CSV文件,请求参数乱码 1.修改本地配置文件,jmeter.properties,修改以下配置项 sampleresult.default.encoding=UTF-8 重启Jmet ...

  2. mysql数据库之存储过程

    存储过程(Stored Procedure)是在大型数据库系统中,一组为了完成特定功能的SQL 语句集,存储在数据库中,经过第一次编译后调用不需要再次编译,用户通过指定存储过程的名字并给出参数(如果该 ...

  3. Git命令的总结

    Git 是当前最流行的版本控制程序之一,文本包含了 Git 的一些基本用法 创建 git 仓库 初始化 git 仓库 mkdir project  # 创建项目目录cd project  # 进入到项 ...

  4. 如何申请百度小程序的appid(目前不支持个人账号申请)

    一.搜索百度智能小程序,并使用百度账号登陆 填写相关资料进入审核阶段,审核成功即可进入百度小程序开发者后台.打开“智能小程序首页”-“设置”-“开发设置”, 查看百度小程序的 AppID

  5. 使用window10系统搭建完善的Linux开发环境

    https://juejin.im/post/5d22e46ee51d45775746b9b1 导读 在使用window系统开发时由于系统环境和线上环境不一致可能导致各种问题,以及部分扩展库只支持li ...

  6. nginx的高级配置和优化

    Nginx的高级配置(优化) 针对内核的配置优化 1)net.core.netdev_max_backlog 表示当网络接口接收数据包的速度大于内核处理这些包块的时候,允许发送到队列的数据包的最大数目 ...

  7. Java并发(基础知识)—— 创建、运行以及停止一个线程

    在计算机世界,当人们谈到并发时,它的意思是一系列的任务在计算机中同时执行.如果计算机有多个处理器或者多核处理器,那么这个同时性是真实发生的:如果计算机只有一个核心处理器那么就只是表面现象. 现代所有的 ...

  8. 第04课:GDB常用命令详解(上)

    本课的核心内容如下: run命令 continue命令 break命令 backtrace与frame命令 info break.enable.disable和delete命令 list命令 prin ...

  9. [ZJOI2014]力 题解

    题目地址 洛谷P3338 Solution 第一道FFT的应用AC祭! 我们要求: \[E_j=\frac{F_j}{q_j}=\sum_{i<j}\frac{q_i}{(i-j)^2}-\su ...

  10. spring AspectJ的Execution表达式(转载)

    原文:http://blog.csdn.net/peng658890/article/details/7223046 在使用spring框架配置AOP的时候,不管是通过XML配置文件还是注解的方式都需 ...