1 class Solution { 2 public boolean containsDuplicate(int[] nums) { 3 HashMapm = new HashMap (); 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 }
本文共 444 字,大约阅读时间需要 1 分钟。
1 class Solution { 2 public boolean containsDuplicate(int[] nums) { 3 HashMapm = new HashMap (); 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