There are two arrays (vectors, there is no difference what container to use) you need to find two elements that are in both the first and second. In addition to ideas about enumerating all the numbers, I did not invent anything.
You can of course use lower_bound for optimization.
But I need a quick response to the request (constant at best, because I can have a lot of arrays and also requests, about 1000 ).
How can this be done ? Perhaps there is some kind of algorithm that solves this problem.