I was looking for other topics with a similar problem, but I could not find a single one applicable to me. If I have a variable that has some value, and an array that has a list of values ββ... is it possible for me efficiently (effective time, space is not a limitation), find out the index of the array when the variable matches the element of the array?
I get a variable from reading from a massive file, and brute force repeating every opportunity would mean several million iterations. I am ready to do this as a last resort, but I would rather not do it. :)
I program in C if the algorithm depends on it. I have no way to program in C ++ / Python. Thanks!
Edit: the value that I want to combine with the array falls into pairs (x, y). If the array matches x or y, I process (x, y). But it is very important that the order does not change if I have to sort it, for example.
source share