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.

Subscribe to see which companies asked this question

bool containsDuplicate(vector<int>& nums) {
unordered_map<int, int> hash;
for (auto i : nums)
{
if (hash.find(i) == hash.end())
hash.insert(make_pair(i, ));
else
return true;
}
return false;
}

Contains Duplicate leetcode的更多相关文章

  1. 217. Contains Duplicate (leetcode)

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

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

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

  3. [LeetCode] Find the Duplicate Number 寻找重复数

    Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), pro ...

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

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

  5. [LeetCode] Contains Duplicate II 包含重复值之二

    Given an array of integers and an integer k, return true if and only if there are two distinct indic ...

  6. [LeetCode] Contains Duplicate 包含重复值

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

  7. [LeetCode] Delete Duplicate Emails 删除重复邮箱

    Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique ...

  8. [LeetCode] Duplicate Emails 重复的邮箱

    Write a SQL query to find all duplicate emails in a table named Person. +----+---------+ | Id | Emai ...

  9. LeetCode Remove Duplicate Letters

    原题链接在这里:https://leetcode.com/problems/remove-duplicate-letters/ 题目: Given a string which contains on ...

随机推荐

  1. Java jsp基本结构

    <!DOCTYPE html> <!-- [ published at 2015-11-13 12:30:50 ] --> <html> <head> ...

  2. 企业为什么要实行ERP系统,它到底有什么好处呢?

    目前,我国正在大力推行企业信息化建设,作为一种包含了现代管理思想的ERP(Enterprise Resource Planning)系统日益成为现代企业业务运作的主要工具,为了提升管理水平,提升企业竞 ...

  3. Servlet的请求HttpServletRequest

    一.从容器到HttpServlet 1.web容器作了什么 web容器做的事情就是,创建Servlet实例,并完成Servlet的名称注册及URL模式的对应.在请求来到时,web容器会转发给正确的Se ...

  4. localToLocal坐标变换

    localToLocal坐标变换 $(function() { init(); }); // localtoLocal var stage, arm, handler; function init(e ...

  5. 使用IntelliJ IDEA开发SpringMVC网站(一)开发环境

    使用IntelliJ IDEA开发SpringMVC网站(一)开发环境 摘要: 主要讲解初期的开发环境搭建,Maven的简单教学. 访问GitHub下载最新源码:https://github.com/ ...

  6. CentOS7系统安装DNS服务

    CentOS7系统安装DNS服务 30.1.DNS是什么? DNS ( Domain Name System )是"域名系统"的英文缩写,简单来说就是一个数据库,用于存储网络中IP ...

  7. jmeter测试计划

    测试计划配置 用户定义的变量: 测试计划上可以添加用户定义的变量.一般添加一些系统常用的配置.如果测试过程中想切换环境,切换配置,一般不建议在测试计划上添加变量,因为不方便启用和禁用,一般是直接添加用 ...

  8. .net判断System.Data.DataRow中是否包含某列

    大家对将DataRow转成实体对象并不陌生,转成实体的时候一般都会加上这个判断  if (row["字段名"] != null && row["字段名&q ...

  9. Hibernate核心配置文件

    Hibernate.cfg.xml是Hibernate操作数据库的核心配置文件 *********************************************** 作用 01.管理实体类的 ...

  10. ECMAScript 6 笔记(六)

    编程风格 1. 块级作用域 (1)let 取代 var (2)全局常量和线程安全 在let和const之间,建议优先使用const,尤其是在全局环境,不应该设置变量,只应设置常量. const优于le ...