1. 程式人生 > >LeetCode#217: Contains Duplicate

LeetCode#217: Contains Duplicate

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