How can I check if all elements of vector_a also appear in the same order as vector_b?
vector_b could be very long, there is no assumption that it is sorted, but it does not have duplicate elements.
I could not find a method implemented for Vec or in itertools, so I tried implementing by doing:
- Create a hashmap from
vector_bmappingvalue -> index - Iterate over
vector_band check that:- Element exists in hashmap
- Index is strictly greater than previous element's index
I am not really happy with this as it is not space efficient due to the creation of the hashmap.