217. Contains Duplicate

public class Solution {
    public boolean containsDuplicate(int[] nums) {
        Map<Integer,Integer> mp=new HashMap<Integer,Integer>();
        int len=nums.length;
        for(int i=0;i<len;i++)
        {
            if(mp.containsKey(nums[i]))
                return true;
            mp.put(nums[i],1);
        }
        return false;
        
    }
}

 

posted @ 2016-04-02 20:38  阿怪123  阅读(109)  评论(0编辑  收藏  举报