Leetcode no. 217
来源:互联网 发布:我的世界起床战争端口 编辑:程序博客网 时间:2024/05/16 10:41
217. Contains Duplicate
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.length==0) return false; Set<Integer> set= new HashSet<>(); for (int ele: nums) { if (set.contains(ele)) return true; set.add(ele); } return false; }}
0 0
- Leetcode no. 217
- Leetcode NO.217 Contains Duplicate
- LeetCode--No.217--Contains Duplicate
- LeetCode No.11 ~No.12
- Leetcode NO.78 Subsets
- Leetcode NO.77 Combinations
- Leetcode NO.46 Permutations
- 【leetcode】No. 235 LCABST
- LeetCode no. 35
- Leetcode no. 37
- Leetcode no. 279
- Leetcode no. 335
- Leetcode no. 283
- Leetcode no. 181 (sql)
- Leetcode no. 40
- Leetcode no. 238
- Leetcode no. 26
- Leetcode no. 80
- 5-30 字符串的冒泡排序 (20分)
- 学习篇---刮刮卡
- 具有弹性效果的ListView
- 5-31 字符串循环左移 (20分)
- arraylist转array数组
- Leetcode no. 217
- js动态创建按钮
- printf()输出缓存问题
- 打包上传时遇到的各种错误总结
- linux 2.6.30 内核编译 提示 ‘make[1]: *** [arch/x86/vdso/vdso.so.dbg] Error 1’ 错误
- 第六次c++作业
- 5-32 说反话-加强版 (20分)
- JEE开发1——OJDBC版本区别 [ojdbc14.jar,ojdbc5.jar和ojdbc6.jar的区别]
- 5-33 有理数加法 (15分)