您的位置:首页 > 大数据 > 人工智能

Algorithms—217.Contains Duplicate

2015-07-30 22:01 405 查看
思路:遍历

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


耗时:456ms,中游

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: