LeeCode-Contains Duplicate
2016-04-25 18:50
531 查看
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==0||numsSize==1)
return false;
bool flag=false;
for(int i=0;i<numsSize-1;i++)
{
flag=false;
for(int j=i+1;j<numsSize;j++)
{
if(nums[i]==nums[j])
{
flag=true;
}
if(flag)
return true;
}
}
return false;
}
相关文章推荐
- 关于main函数中argc和argv的简单介绍
- Fast-Start Failover工作过程及实例
- OpenGL vs2010 ActiveX Control Test Container
- B. Kuriyama Mirai's Stones
- POJ2010-Moo University - Financial Aid
- 设计模式之---责任链模式(Chain of Responsibility)
- 异常信息ASM ClassReader failed to parse class file的问题解决
- SLF4J: Class path contains multiple SLF4J bindings.
- HDU 1848 Fibonacci again and again Nim博弈变形
- failed: Too many links 解决
- 1215 - Cannot add foreign key constraint
- POJ 1273 —— Drainage Ditches 入门题
- AIR开发手机 相关文档
- RAID总结
- <OJ_Sicily>1_D closet pair最近邻点对
- Flume-ng TaildirSource 填坑
- HDU 1789 Doing Homework again
- ssdtrain demo
- handler.obtainMessage()与new Message的区别
- CPaintDC、CClientDC、CWindowDC和CMetaFileDC类的主要特点及区别