So, I have A = {1,3,3,4}
B = {5,4,7,3}
I want to see how many times the elements of array B appear in array A, however I only want to count each element once in array A. Therefore, if 3 appears several times, 3 will be counted only once, and therefore forward.
Here my answer will be 2, since I have 3.4 that are in array B, which are also in array A.
This is what I have so far:
int count = 0;
for(int z = 0; z <4; z++)
{
for(int y = 0; y <4; y++)
{
if(arrayA[z] == arrayB[y])
{
count++;
}
}
}
When I run this, I get 3. I know why. I count duplicates in an array A {3,3,4}. How not to count them? I am stuck.
This is a secondary feature that Iām stuck with all the time.