Skip to content

Instantly share code, notes, and snippets.

@kingsamadesu
Created December 3, 2020 20:35
Show Gist options
  • Save kingsamadesu/fcee9b000584fa0fad18fee25c173136 to your computer and use it in GitHub Desktop.
Save kingsamadesu/fcee9b000584fa0fad18fee25c173136 to your computer and use it in GitHub Desktop.
217. Contains Duplicate -with java- (leetcode.com)
/*
Your runtime beats 79.51 % of java submissions.
Your memory usage beats 69.24 % of java submissions.
*/
class Solution {
public boolean containsDuplicate(int[] nums) {
Set<Integer> set = new HashSet<Integer>();
for(int i = 0 ; i < nums.length ; i++){
if(!set.add(nums[i])){return true;}
}
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment