Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save daubattu/bfca162d74b39c1726ecf98f836c9d51 to your computer and use it in GitHub Desktop.
Save daubattu/bfca162d74b39c1726ecf98f836c9d51 to your computer and use it in GitHub Desktop.
[Hackerrank] Solution of Beautiful Triplets in JavaScript
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;
}
@MSaqibNazir
Copy link

it is wrong solution

@theinterseller
Copy link

its wrong for other test case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment