JSFiddle - React, Tailwind, and code Playground
JavaScript
alert(uniq ([
[1,2,3,4,5,1],
[90,7,2],
[3,4,5,10]
]))
function uniq (arr) {
let c = 0;
for (let a of arr) {
c += a.length
for (let v of a) {
let x = 0
n: for (let b of arr) {
let r = 0
for (let i of b) {
if (i === v) {
if (x < 2) c--
x++
if (a === b && (++r) < 2) c++
}
if (r > 2) continue n;
}
}
}
}
return c;
}