leetcode 217. Contains Duplicate
2016-03-15 09:57
585 查看
题目内容
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.
题目分析
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) { Set<Integer> unique=new HashSet<Integer>(); for(int x: nums) { if(unique.contains(x)) return true; else unique.add(x); } return false; } }
相关文章推荐
- 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 連線時應如何處理
- 服务器TIME_WAIT和CLOSE_WAIT详解和解决办法
- 我的人工智能学习之路(1)
- CLOSE_WAIT状态的原因与解决方法
- HDU 2674 N!Again (数论)
- 深度学习之google deepmind的alphago AI人工智能算法技术演变历程
- What does 'if __name__=='__main__' do
- poj3250Bad Hair Day(单调栈)
- leetcode 70. Climbing Stairs
- HDU.1022 Train Problem I【栈的简单应用】(3.14)
- HDU4300 Clairewd’s message
- 【leetcode】第11题:Container问题
- 关灯游戏AI扩展