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. spring boot 是如何加载jackson的?

    Spring Boot 自动引入jackson: 通过:Spring-Boot-starter-web Jackson自动配置 这里的configurations是读取的这里: 通过反射加载Jacks ...

  2. javascript伪链接(javascript:)

    前言 我们经常会看到“javascript:”这种情况,他经常会用在两种属性身上,href和onclick等事件处理器,接下里我们主要说用在onclick等事件处理器上的情况,在href中的应用在之前 ...

  3. SSH自动登录config文件配置

    title: SSH自动登录config文件配置 comments: false date: 2019-08-19 19:29:13 description: 更方便的 ssh 操作??? categ ...

  4. Host xxx is not allowed to connect to this MariaDb server

    直接复制代码,无需修改 第一:// %:表示从任何主机连接到mysql服务器 GRANT ALL PRIVILEGES ON *.* TO 'user'@'%' IDENTIFIED BY 'pass ...

  5. Linux操作系统笔记

    #include <stdio.h> #include <stdlib.h> #include <unistd.h> //linux下面的头文件 #include ...

  6. SIP协议 会话发起协议(二)

    SIP - 响应码 SIP响应是由用户代理服务器(UAS)或SIP服务器生成的用于回复客户端生成的请求的消息.这可能是一个正式的确认,以防止UAC转发请求. 响应可能包含UAC所需的一些额外的信息头字 ...

  7. 一、H5(移动端)前端使用input type=file 上传图片,调用相机和相册

    一.H5(移动端)前端使用input type=file 上传图片,调用相机和相册

  8. vs开发之工程属性

    1.建立工程 最好使用自己创建工程 然后把代码移过去 2.不要使用别人建立的工程直接导入(差异比较大的话),后面32位 64位 配置属性 可能造成冲突 3.冲突了 还需要重新做 上面 1

  9. tensorboard_embedding

    from tensorboardX import SummaryWriter import torchvision writer=SummaryWriter(log_dir="embeddi ...

  10. Mybatis 动态sql(转载)

    原文地址:http://www.cnblogs.com/dongying/p/4092662.html 传统的使用JDBC的方法,相信大家在组合复杂的的SQL语句的时候,需要去拼接,稍不注意哪怕少了个 ...