Questions d'entretien
Entretien pour Machine Learning Developer
-
AmazonPlease code up and send me a function that takes two integer arrays and returns their intersection. This answer must take less than n^2 time.
Répondre
Réponses aux questions d'entretien
3 réponse(s)
▲
0
▼
Use a hash table or tree.
Utilisateur anonyme le
▲
0
▼
modify merge sort
Student le
▲
0
▼
sample outline of O(n log n) algorithm : a.sort(); b.sort(); list c={}; int i1=0,i2=0; while(true) { if(i1==n || i2==n) break; if(a[i1]==b[i2]) { c.insert(a[i1]); i1++; i2++; }else { if(a[i1] < b[i2]) i1++; else i2++; } } return c;
Ali le
Ajouter des réponses ou des commentaires
Pour commenter ceci, connectez-vous ou inscrivez-vous.