Skip to content

Commit a73e2c5

Browse files
committed
contains duplicate solution
1 parent f291ae8 commit a73e2c5

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

contains-duplicate/RiaOh.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* @param {number[]} nums
3+
* @return {boolean}
4+
*/
5+
var containsDuplicate = function (nums) {
6+
let count = [nums[0]];
7+
for (let i = 1; i < nums.length; i++) {
8+
if (count.includes(nums[i])) {
9+
return true;
10+
} else {
11+
count.push(nums[i]);
12+
}
13+
}
14+
return false;
15+
};

0 commit comments

Comments
 (0)