Leetcode_217_存在重复元素_水题

12/13

水题

class Solution {
    
    
    public boolean containsDuplicate(int[] nums) {
    
    
        Map<Integer,Boolean>m=new HashMap<>();
        for(int i:nums){
    
    
            if(m.containsKey(i)){
    
    
                return true;
            }
            m.put(i,true);
        }
        return false;
    }
}

猜你喜欢

转载自blog.csdn.net/HDUCheater/article/details/111088871
今日推荐