You are viewing a single comment's thread. Return to all comments →
function beautifulTriplets(d, arr) {
let hash = {} let counter = 0 for (const n of arr) { hash[n] = !hash[n] ? 1 : hash[n] + 1; } for (const k in hash) { const sec = Number(k) + d; const third = sec + d; if (hash[sec] && hash[third]) counter += Math.max(hash[k], hash[sec], hash[third]) } return counter
}
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 →
function beautifulTriplets(d, arr) {
}