首页 > 其他 > 详细

LeetCode 217

时间:2020-06-18 01:28:22      阅读:53      评论:0      收藏:0      [点我收藏+]

217. 存在重复元素

Java

class Solution {
    public boolean containsDuplicate(int[] nums) {
        Set<Integer> s = new HashSet<>();
        for(int i = 0 ; i<nums.length ; i++){
            if(s.contains(nums[i])){
                return true;
            }
            s.add(nums[i]);
        }
        return false;
    }
}

LeetCode 217

原文:https://www.cnblogs.com/xkf97/p/13155320.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!