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. 15. AutoMapper 之映射继承(Mapping Inheritance)

    https://www.jianshu.com/p/e4f05403bd13 映射继承(Mapping Inheritance) 映射继承有两个功能: 从基类或接口配置继承映射配置 运行时多态映射 继 ...

  2. $id(id)函数

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  3. Delphi 布尔型数据

  4. tomcat中部署多个项目,webAppRootKey 参数配置

    在一个tomcat中部署多个项目时,需要在每个项目的web.xml中配置webAppRootKey参数,如下: <context-param> <param-name>webA ...

  5. AIX中的页空间管理

    1.页空间简介(Paging  Space) 页空间是指硬盘上的存储内存信息的区域. 一个页空间也叫做一个交换空间. 是系统中一个类型为paging的逻辑卷.       2.创建页空间 使用mkps ...

  6. zabbix利用percona-toolkit工具监控Mysql主从同步状态

    一.下载percona-toolkit工具包 percona-toolkit是一组高级命令行工具的集合,可以查看当前服务的摘要信息,磁盘检测,分析慢查询日志,查找重复索引,实现表同步等等. [root ...

  7. python算法(一)基本知识&冒泡排序&选择排序&插入排序

    本节内容: 算法基本知识 冒泡排序 选择排序 插入排序 1. 算法基本知识 1.1 什么是算法? 算法(algorithm):就是定义良好的计算过程,他取一个或一组的值为输入,并产生出一个或一组值作为 ...

  8. grpc 学习

    RPC概念:(参考:http://www.imooc.com/article/285514) RPC(远程过程调用)一般用来实现部署在不同机器上的系统之间的方法调用,使得程序能够像访问本地系统资源一样 ...

  9. 十三、S3C2440 裸机 — 初始化代码及MMU

    13.1 NOR FLASH 搬运 把程序从 nor flash 上搬运到 SDRAM 中 程序存储在 nor flash 上,运行时将程序搬运到 SDRAM 中运行 nor flash 启动:nor ...

  10. CF 1272F Two Bracket Sequences (括号dp)

    题目地址 洛谷CF1272F Solution 首先题目中有两个括号串 \(s\) 和 \(t\) ,考虑先设计两维表示 \(s\) 匹配到的位置和 \(t\) 匹配到的位置. 接着根据 括号dp的一 ...