博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[LeetCode&Python] Problem 217. Contains Duplicate
阅读量:4347 次
发布时间:2019-06-07

本文共 577 字,大约阅读时间需要 1 分钟。

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.

Example 1:

Input: [1,2,3,1]Output: true

Example 2:

Input: [1,2,3,4]Output: false

Example 3:

Input: [1,1,1,3,3,4,3,2,4,2]Output: true
class Solution(object):    def containsDuplicate(self, nums):        """        :type nums: List[int]        :rtype: bool        """        return len(nums)!=len(list(set(nums)))

  

转载于:https://www.cnblogs.com/chiyeung/p/9999622.html

你可能感兴趣的文章
前台实现ajax 需注意的地方
查看>>
Jenkins安装配置
查看>>
深入理解Java虚拟机&运行时数据区
查看>>
02-环境搭建
查看>>
spring第二冲刺阶段第七天
查看>>
搜索框键盘抬起事件2
查看>>
透析Java本质-谁创建了对象,this是什么
查看>>
BFS和DFS的java实现
查看>>
关于jquery中prev()和next()的用法
查看>>
一、 kettle开发、上线常见问题以及防错规范步骤
查看>>
eclipse没有server选项
查看>>
CRC码计算及校验原理的最通俗诠释
查看>>
使用Gitbook来编写你的Api文档
查看>>
jquery扩展 $.fn
查看>>
Markdown指南
查看>>
influxDB的安装和简单使用
查看>>
JPA框架学习
查看>>
JPA、JTA、XA相关索引
查看>>
机器分配
查看>>
php opcode缓存
查看>>