You are viewing a single comment's thread. Return to all comments →
javascript
function triplets(a, b, c) { let cleanA = [...new Set(a)].sort((a, b) => a - b) let cleanB = [...new Set(b)].sort((a, b) => a - b) let cleanC = [...new Set(c)].sort((a, b) => a - b) let count = 0 for (let i = 0; i < cleanB.length; i++) { let howManyA = cleanA.findIndex(v => v > cleanB[i]) let howManyC = cleanC.findIndex(v => v > cleanB[i]) if (howManyA == -1) howManyA = cleanA.length if (howManyC == -1) howManyC = cleanC.length count += howManyA * howManyC } return count }
Seems like cookies are disabled on this browser, please enable them to open this website
Triple sum
You are viewing a single comment's thread. Return to all comments →
javascript