Consider the array below:
let array = [[1, 2], [1, 2], [3, 4], [5, 6], [2, 1]]
I am looking for a way to determine the number of unique arrays in this set. Using the array above as an example, the expected result is 3
. How can I achieve this? The code snippet provided below was my attempt, but it doesn't yield the correct output.
let distinct = 0
for (let i = 0; i < array.length; i++) {
for (let j = i + 1; j < array.length - i; j++) {
let difference = ingredients[i].filter(x => !array[j].includes(x))
if (difference.length > 0) {
distinct += 1;
}
}
}
return distinct;