LeetCode 217 Contains Duplicate
2015-12-08 16:30
148 查看
题目描述
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.代码
[code] public static boolean containsDuplicate(int[] nums) { Set<Integer> s = new HashSet<Integer>(); for (int n : nums) { if (s.contains(n)) { return true; } s.add(n); } return false; }
相关文章推荐
- 浅谈RAID写惩罚与IOPS计算[转载]
- UVA 11029 Leading and Trailing
- 事件传递之响应链(Event Delivery: The Responder Chain)【转】
- 游戏AI - 行为树Part2:框架
- 游戏AI - 行为树Part1:简介
- XeTeX: “Failed to convert input string to UTF16″
- LSI MegaRAID(IBM服务器web页面) 8708E SAS RAID卡如何使用手动方式创建RAID5+热备盘
- maven 遇到failOnMissingWebXml有关问题解决方法
- 线程状态的区别 blocked waitting ,join 详解
- 解决 ld: library not found for -xxx linker command failed with exit code 1 (use -v to see invocation)
- wait、waitpid详解
- Failed to install Hi.apk on device ‘emulator-5554′: EOF
- 人工智能系统
- 32位的ane与air sdk升级
- 决绝Capturing 'demo' strongly in this block is likely to lead to a retain cycle
- WebLogic启动报错“Unable to obtain file lock but will retry”
- 【Codeforces Round 271 (Div 2)C】【暴力 坐标变换】Captain Marmot 四个点绕中心旋转 最小步数使得构成正方形
- adb shell之后 ls: openir failed, Permission denied
- Microsoft.AlphaImageLoader
- Failed to access IIS metabase解决方式