LeeCode-Contains Duplicate

时间:2022-06-05 13:44:39

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.

 bool containsDuplicate(int* nums, int numsSize)
{
if(numsSize==||numsSize==)
return false; bool flag=false;
for(int i=;i<numsSize-;i++)
{
flag=false;
for(int j=i+;j<numsSize;j++)
{
if(nums[i]==nums[j])
{
flag=true;
}
if(flag)
return true;
}
} return false;
}