Question d’entretien chez Epic

find an intersection between integer arrays

Réponses aux questions d'entretien

Utilisateur anonyme

29 sept. 2011

A faster way is to determine which is the smaller array, sort it, then use binary search to determine which of the larger array is in the smaller array. Total time complexity is O((n+m)log m) where m is the size of the smaller list and n is the size of the larger array. this is better than the previous answer which is n*m.

2

Utilisateur anonyme

5 mai 2010

given arrays a and b dim c() z=0 for x= 0 to ubound(a) -1 for y= 0 to ubound(b) -1 if b(y) = a(y) then z=z+1 redim.preserve c(z) c(z-1) = b(y) endif next y next x