217 Contains Duplicate (Array)

Posted gopanama

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了217 Contains Duplicate (Array)相关的知识,希望对你有一定的参考价值。

 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)的主要内容,如果未能解决你的问题,请参考以下文章

LeetCode_217. Contains Duplicate

217. Contains Duplicate

LeetCode 217. Contains Duplicate

217 Contains Duplicate

LeetCode 217 Contains Duplicate

217. Contains Duplicate (leetcode)