Created
January 10, 2020 09:06
-
-
Save daubattu/bfca162d74b39c1726ecf98f836c9d51 to your computer and use it in GitHub Desktop.
[Hackerrank] Solution of Beautiful Triplets in JavaScript
This file contains hidden or 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
function beautifulTriplets(d, arr) { | |
let result = 0; | |
for (let i = 0; i < arr.length; i++) { | |
const numb1 = arr[i] - d; | |
const numb2 = numb1 - d; | |
if (arr.includes(numb1) && arr.includes(numb2)) { | |
result += 1; | |
} | |
} | |
return result; | |
} |
its wrong for other test case
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
it is wrong solution