leetcode之217. Contains Duplicate(C++解法)

来源:互联网 发布:域名cc是外国的吗? 编辑:程序博客网 时间:2024/06/05 15:28

原题:
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 {
public:
bool containsDuplicate(vector& nums) {
set coun;
for(auto i: nums)
{
bool check=coun.insert(i).second;
if(!check)
return true;
}
return false;
}
};

0 0
原创粉丝点击