I've searched for other threads with a similar problem, but I couldn't find any that apply to me. If I have a variable which has some value, and an array that has a list of values... is it possible for me to efficiently (time efficient, space isn't a constraint) find out the index of the array when the variable matches an element in the array?
I'm getting the variable from reading out of a massive file, and brute force iterating over every possibility will mean several million iterations. I'm willing to do that as a last resort, but I'd rather not. :)
I'm programming in C, if the algorithm depends on that. I don't have an option to program in C++/Python. Thanks!
Edit : The valued that I want to match with the array come in pairs (x,y). If the array matches with x or y, I further process (x,y). But it's vital that the ordering not change if I have to sort it for example.