So this is a simpler form of my problem.
Lets say I have 2 arrays. A= {1,2} and B={2,4,6}.
If A and B share an element then delete that element from B.
I know you can loop through and compare each element in A to each element in B, but there’s got to be a better way!
So this is a simpler form of my problem. Lets say I have 2
Share
If your arrays are sorted (or you can sort the arrays), you can then work through both arrays simultaneously. Starting at the beginning of both arrays and going until you would advance one of the pointers beyond the end of its respective array: