1、力扣原题
https://leetcode-cn.com/problems/contains-duplicate/
- 思路:哈希表
class Solution {
public boolean containsDuplicate(int[] nums) {
Map<Integer,Integer> map = new HashMap<>();
int counts = nums.length;
for (int i = counts; i < counts; i++) {
int key = nums[i];
int value = i;
if ((map.get(key)) == nums[i]) return true;
map.put(key,value);
}
return false;
}
}