leetcode217:Contains Duplicate
2016-03-15 13:10
513 查看
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.
public class Solution { public boolean containsDuplicate(int[] nums) { if(nums==null||nums.length<2) return false; HashSet<Integer> set=new HashSet<Integer>(); for(int i:nums){ if(!set.add(i)){ return true; } } return false; } }
相关文章推荐
- opencv中stitching_detail的运行
- Codeforces 627B Factory Repairs 线段树
- git中Please enter a commit message to explain why this merge is necessary.
- Mongo运行错误:Failed to connect 127.0.0.1:27017,reason:errno:10061由于目标计算机积极拒绝,无法连接
- dmraid
- 磁盘管理之RAID
- ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction
- 如何进行rails性能优化
- time_wait和close_wait状态
- <interface declaration>, <parcelable declaration>, AidlTokenType.import or AidlTokenType.package ...
- LeetCode: Container With Most Water
- leetcode 217. Contains Duplicate
- Android Volley完全解析(二),使用Volley加载网络图片 转载:http://blog.csdn.net/guolin_blog/article/details/174
- Android Volley完全解析(一),初识Volley的基本用法 转载地址:http://blog.csdn.net/guolin_blog/article/details/17482095
- air jordan shoes jordan new shoes
- 人机大战输赢不重要!重要的是说人话
- Time.timeScale 对 协程WaitForSeconds的影响
- LeetCode #11 Container With Most Water 最大容器 解题小节
- #345 Div2 B. Beautiful Paintings
- 在 Windows 上遇到非常多 TIME_WAIT 連線時應如何處理