You are viewing a single comment's thread. Return to all comments →
JS all pass
function triplets(a, b, c) { let cleanA = [...new Set(a)].sort((x, y) => x - y) let cleanB = [...new Set(b)] let cleanC = [...new Set(c)].sort((x, y) => x - y) let count = 0 for (let i = 0; i < cleanB.length; i++) { let numOfP = 0, numOfQ = 0 for (let j = cleanA.length; j > 0; j--) { if (cleanA[j - 1] <= cleanB[i]) { numOfP = j break } } for (let j = cleanC.length; j > 0; j--) { if (cleanC[j - 1] <= cleanB[i]) { numOfQ = j break } } count += numOfP * numOfQ } 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 →
JS all pass