Created
December 3, 2020 20:35
-
-
Save kingsamadesu/fcee9b000584fa0fad18fee25c173136 to your computer and use it in GitHub Desktop.
217. Contains Duplicate -with java- (leetcode.com)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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