Skip to content

Commit 0a1dec3

Browse files
committed
📝 Solved: #217
1 parent 345fb9b commit 0a1dec3

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

contains-duplicate/jangwonyoon.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* @param {number[]} nums
3+
* @return {boolean}
4+
*/
5+
var containsDuplicate = function(nums) {
6+
const sortedNums = nums.sort((a, b) => a - b);
7+
const length = sortedNums.length - 1;
8+
9+
for (let i = 0; i < length; i++) {
10+
const left = nums[i];
11+
const right = nums[i + 1];
12+
13+
if (left === right) {
14+
return true;
15+
}
16+
}
17+
18+
return false;
19+
};

0 commit comments

Comments
 (0)