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 }
原文地址:https://www.cnblogs.com/goPanama/p/9375119.html
时间: 2024-10-14 06:21:32