Skip to content

Commit baa48d8

Browse files
committed
contains-duplicate
1 parent 53ce7c7 commit baa48d8

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

contains-duplicate/jun0811.js

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

0 commit comments

Comments
 (0)