in reply to Re^4: Better way to do this
in thread Better way to do this
Given two arrays @unique and @in, find the index, @idxs into @unique of the element of @inFirst, store the elements of @in into a hash (as hash keys, corresponding value doesn't matter)). Then just scan once the @unique array and, for each item, see if it exists in the hash. If if does, keep track of the index of that item, perhaps in the hash, perhaps in another array (you don't give enough details to decide what is best). This will be very fast (and, since this is an O(n) complexity, n being the size of the @unique array, it is probably not possible to find a faster algorithm, because you can't skip reading both arrays at least once, so that, at best, you'll improve details).
I want to return each elements which between two consecutive indexes (@idxs) if 10< Length > 5.Sorry, I don't understand your second requirement.
|
|---|