Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element is distinct.

class Solution:
# @param {integer[]} nums
# @return {boolean}
def containsDuplicate(self, nums):
if len(nums) <= 0:
return False
arrCheck = {}
for i in nums:
if arrCheck.has_key( i ):
return True
arrCheck[i] = i
return False

leetcode Contains Duplicate python的更多相关文章

  1. leetcode Contains Duplicate II python

    Given an array of integers and an integer k, find out whether there are two distinct indices i and j ...

  2. [LeetCode]题解(python):090 Subsets II

    题目来源 https://leetcode.com/problems/subsets-ii/ Given a collection of integers that might contain dup ...

  3. [LeetCode]题解(python):078 Subsets

    题目来源 https://leetcode.com/problems/subsets/ Given a set of distinct integers, nums, return all possi ...

  4. [LeetCode]题解(python):082 - Remove Duplicates from Sorted List II

    题目来源 https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii/ Given a sorted linked list ...

  5. [LeetCode]题解(python):040-Combination Sum II

    题目来源 https://leetcode.com/problems/combination-sum-ii/ Given a collection of candidate numbers (C) a ...

  6. [LeetCode]题解(python):039-Combination Sum

    题目来源 https://leetcode.com/problems/combination-sum/ Given a set of candidate numbers (C) and a targe ...

  7. [LeetCode]题解(python):033-Search in Rotated Sorted Array

    题目来源 https://leetcode.com/problems/search-in-rotated-sorted-array/ Suppose a sorted array is rotated ...

  8. [LeetCode] Remove Duplicate Letters 移除重复字母

    Given a string which contains only lowercase letters, remove duplicate letters so that every letter ...

  9. [LeetCode] Contains Duplicate III 包含重复值之三

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

随机推荐

  1. 跟我一起学extjs5(24--模块Form的自己定义的设计[2])

    跟我一起学extjs5(24--模块Form的自己定义的设计[2])         在本节中将要增加各种类型的字段,在增加字段的时候因为能够一行增加多个字段,因此层次结构又多了一层fieldcont ...

  2. js复制button在ie下的解决方式

    源代码例如以下: <input class="width200" maxlength="32" type="text" id=&quo ...

  3. Intellij Idea的一些配置

    1.字体 修改IDEA面板字体:Settings->Appearance-> Override default fonts by(not recommended)选中,选择自己喜欢的字体 ...

  4. OpenCV学习(2)--基本数据结构

    OpenCV的基本数据结构 CvPoint:表示图像中的点 CvPoint2D32f:二维空间中的点 CvPoint3D32f:三维空间中的点 这些都是结构体,并不是C++语言中的类,所以他们的构造函 ...

  5. shell脚本定时备份数据库

    脚本代码: 新建文件back_db.sh #!/bin/bash TODAYTIME="`date +%Y%m%d`" DBNAME="test mysql" ...

  6. SUBSTRING_INDEX ——网上的解释

    SUBSTRING_INDEX(str,delim,count)    Returns the substring from string str before count occurrences o ...

  7. mysql 与 mysqli的区别

    mysqli.dll是PHP对mysql新特性的一个扩展支持.在PHP5中可以在php.ini中加载mysql后面的i,指improved, interface, ingenious, incompa ...

  8. php笔试算法题:顺时针打印矩阵坐标-蛇形算法

    这几天参加面试,本来笔试比较简单,但是在面试的时候,技术面试官说让我现场写一个算法,顺时针打印矩阵的坐标,如图所示 顺序为,0,1,2,3,4,9,14,19,24,23,22,21,20,15,10 ...

  9. try.jquery-5-styling里的各种css样式操作

    你好,这里是我的http://try.jquery.com/学习笔记: 这次来学习操作各种css. 主要对这段html元素进行操作. <div id="all-tours"& ...

  10. 编写一个程序实现strcmp函数的功能

    写自己的strcat函数------→mycmp #include <stdio.h> #include <string.h> #define N 5 int mycmp(ch ...