You are viewing a single comment's thread. Return to all comments →
Js Solution
let tripletsCount = 0; for (let i = 0; i < arr.length; i++) { let possibleTriplets = [arr[i]]; let currentValue = arr[i]; for (let j = 0; j < 2; j++) { let nextValue = currentValue + d; if (arr.includes(nextValue)) { possibleTriplets.push(nextValue); currentValue = nextValue; } else { break; } } if (possibleTriplets.length === 3) { tripletsCount++ } } return tripletsCount;
Seems like cookies are disabled on this browser, please enable them to open this website
Beautiful Triplets
You are viewing a single comment's thread. Return to all comments →
Js Solution