contains duplicate in 3 more languages for some reason
This commit is contained in:
parent
2a7ec7e34b
commit
e7b17e4450
|
@ -0,0 +1,14 @@
|
|||
/**
|
||||
* @param {number[]} nums
|
||||
* @return {boolean}
|
||||
*/
|
||||
var containsDuplicate = function(nums) {
|
||||
let exists = {};
|
||||
return nums.some(n => {
|
||||
if (exists[n]) {
|
||||
return true;
|
||||
}
|
||||
exists[n] = true;
|
||||
return false;
|
||||
});
|
||||
};
|
|
@ -0,0 +1,8 @@
|
|||
class Solution:
|
||||
def containsDuplicate(self, nums: List[int]) -> bool:
|
||||
exists = {}
|
||||
for n in nums:
|
||||
if n in exists:
|
||||
return True
|
||||
exists[n] = True
|
||||
return False
|
|
@ -0,0 +1,10 @@
|
|||
function containsDuplicate(nums: number[]): boolean {
|
||||
let exists = {};
|
||||
return nums.some(n => {
|
||||
if (exists[n]) {
|
||||
return true;
|
||||
}
|
||||
exists[n] = true;
|
||||
return false;
|
||||
});
|
||||
};
|
Loading…
Reference in New Issue