Created
August 22, 2018 16:09
-
-
Save pauloportella/10d44755119d5a0d343ac95fc9447bfe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
containsDuplicates = a => a.length > new Set(a).size |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Given an array of integers, write a function that determines whether the array contains any duplicates. Your function should return true if any element appears at least twice in the array, and it should return false if every element is distinct. | |
Example | |
For a = [1, 2, 3, 1], the output should be | |
containsDuplicates(a) = true. | |
There are two 1s in the given array. | |
For a = [3, 1], the output should be | |
containsDuplicates(a) = false. | |
The given array contains no duplicates. | |
Input/Output | |
[execution time limit] 4 seconds (js) | |
[input] array.integer a | |
Guaranteed constraints: | |
0 ≤ a.length ≤ 105, | |
-2 · 109 ≤ a[i] ≤ 2 · 109. | |
[output] boolean | |
[JavaScript (ES6)] Syntax Tips | |
// Prints help message to the console | |
// Returns a string | |
function helloWorld(name) { | |
console.log("This prints to the console when you Run Tests"); | |
return "Hello, " + name; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment