Skip to content

Commit 66c3799

Browse files
committedSep 25, 2021
Add solution #217
1 parent 0ccf41e commit 66c3799

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed
 

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
67|[Add Binary](./0067-add-binary.js)|Easy|
3131
151|[Reverse Words in a String](./0151-reverse-words-in-a-string.js)|Medium|
3232
152|[Maximum Product Subarray](./0152-maximum-product-subarray.js)|Medium|
33+
217|[Contains Duplicate](./0217-contains-duplicate.js)|Easy|
3334
226|[Invert Binary Tree](./0226-invert-binary-tree.js)|Easy|
3435
263|[Ugly Number](./0263-ugly-number.js)|Easy|
3536
264|[Ugly Number II](./0264-ugly-number-ii.js)|Medium|

‎solutions/0217-contains-duplicate.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* 217. Contains Duplicate
3+
* https://leetcode.com/problems/contains-duplicate/
4+
* Difficulty: Easy
5+
*
6+
* Given an integer array `nums`, return `true` if any value appears at least
7+
* twice in the array, and return `false` if every element is distinct.
8+
*/
9+
10+
/**
11+
* @param {number[]} nums
12+
* @return {boolean}
13+
*/
14+
var containsDuplicate = function(nums) {
15+
return new Set(nums).size !== nums.length;
16+
};

0 commit comments

Comments
 (0)
Please sign in to comment.