Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
O((n1 + n2) * log(n2))
looks better to me thanO(n1 * n2)
, I don't know if I am missing something here. It does depend on the relative lengths ofn1
andn2
though.Technically, his solution is more optimal than the other solutions given. If you use
qsort
(O(n2 log n2)
on the avg. case) onarr2
, andbsort
onarr2
for every element inarr1
((O(n1 log n2)
), then you have a time complexity ofO((n1 + n2) * log(n2))
, while the complexity of the other solutions areO(n1 * n2)
.Every solution I've seen in here is O(n^2), safe to say I don't think there's a better way of doing it (You're calling qsort() once and then bsearch() on every iteration, not sure whether that's O(n^2) or not tbh)