码迷,mamicode.com
首页 > 其他好文 > 详细

217 Contains Duplicate (Array)

时间:2018-07-27 01:17:05      阅读:120      评论:0      收藏:0      [点我收藏+]

标签:map   span   ica   put   code   ash   public   duplicate   hashmap   

 1 class Solution {
 2     public boolean containsDuplicate(int[] nums) {
 3         HashMap<Integer, Integer> m = new HashMap<Integer, Integer>();
 4         for(int i = 0; i < nums.length; i++) {
 5             if (m.containsKey(nums[i])) {
 6                 return true;
 7             }else {
 8                 m.put(nums[i], 1);
 9             }
10         }
11         return false;
12     }
13 }

 

217 Contains Duplicate (Array)

标签:map   span   ica   put   code   ash   public   duplicate   hashmap   

原文地址:https://www.cnblogs.com/goPanama/p/9375119.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!