首页 > 编程语言 > 详细

记录leetcode的java提交解答

时间:2020-04-30 00:13:35      阅读:85      评论:0      收藏:0      [点我收藏+]
class Solutions {
	//217.存在重复元素
    public boolean containsDuplicate(int[] nums) {
    	if (nums.length == 0) {
    		return false;
    	}
    	Set<Integer> hashset = new HashSet<>(nums.length);
    	for (int i = 0; i < nums.length - 1; i++) {
    		if (hashset.contains(nums[i])) {
    			return true;
    		}
    		hashset.add(nums[i]);
    	}
    	return false;
    }
}

记录leetcode的java提交解答

原文:https://www.cnblogs.com/hanhande/p/12805882.html

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