Re: Algo for intersection of two integer arrays?



Returns:

struct InterAB {
int indicesOfA [];
int valuesOfA [];
int indicesOfB [];
int valuesOfB [];
}

for your example:

InterAB.{
indicesOfA [] = {1, 3, 4, 5}
valuesOfA [] = {1, 2, 2, 7}
indicesOfB [] = {2, 3, 4, 6}
valuesOfB [] = {1, 2, 2, 7}
}

Hope this clarifies,

Gary

===========

Patricia Shanahan wrote:
ziman137 wrote:
Two arrays A & B, prototyped as int or char, pls return the common
integers or characters (both values & indices in A & B). Hope this
clarifies the confusion.

I still don't get it. Do the matches have to be at the same index, or is
it just that the index gets reported?

Here's an example:

A= 1, 5, 2, 2, 7
B= 0, 1, 2, 2, 3, 7

What should the result be?

Patricia

.



Relevant Pages