题目

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.

分析

判断所给整数序列中有无重复元素。

AC代码

class Solution {
public:
bool containsDuplicate(vector<int>& nums) {
if (nums.empty())
return false; unordered_set<int> us;
int len = nums.size(); for (int i = 0; i < len; ++i)
{
if (us.count(nums[i]) != 0)
return true;
else
us.insert(nums[i]);
}
return false; }
};

最新文章

  1. win7,ubuntu双系统——重装win7后如何恢复ubuntu引导
  2. php启动时候提示PHP startup的解决方法
  3. xampp 提示 This setting can be configured in the file &quot;httpd-xampp.conf&quot;.
  4. Educational Codeforces Round 4 B. HDD is Outdated Technology 暴力
  5. Servlet &amp; JSP - Servlet API Overview
  6. android颜色对应的xml配置值,颜色表
  7. JAVA 泛型练习
  8. win10系统加载ahci驱动的操作方案(Win10之家)
  9. 201521123010 《Java程序设计》第5周学习总结
  10. html5开发学习 html5自学需要怎么学
  11. mystricpy的实现???
  12. img图片占不满整个div
  13. web 基础设置
  14. asp.net core系列 36 WebAPI 搭建详细示例
  15. 从零开始学安全(三十六)●利用python 爆破form表单
  16. Http协议Status状态代码
  17. 【2016.3.19】作业 分析一个很有(wu)趣(liao)的小程序
  18. redis源码学习-skiplist
  19. ory Oathkeeper Ecosystem
  20. Apache服务器的简单配置与安全策略

热门文章

  1. jsp页面包含的几中方式
  2. .NET Core中Circuit Breaker
  3. pom文件jar包缺失问题
  4. 【转】ibatis 中使用select top #pagesize# * from tablename
  5. asp.net重启web应用程序域
  6. 9、数值的整数次方------------&gt;剑指offer系列
  7. web标准、可用性、可访问性
  8. 如何在cmd查看文件内容的md5值
  9. PHP_RAW_POST_DATA特性
  10. EasyUI:Easyui parser的用法