Shawngbk / Leecode

Questions of Leecode
0 stars 0 forks source link

217. Contains Duplicate #80

Open Shawngbk opened 7 years ago

Shawngbk commented 7 years ago

public class Solution { public boolean containsDuplicate(int[] nums) { HashSet set = new HashSet<>(); int count = 1; for(int i = 0; i < nums.length; i++) { if(set.contains(nums[i])) { count++; } else { set.add(nums[i]); } } if(count > 1) return true; else return false; } }

Shawngbk commented 7 years ago

palantir