Write an efficient function
| C++ | |
| Python | |
that returns the -th largest of all the elements contained in and , taking into account repeated elements. For instance, if contains a 5 and a 7, and only contains a 5, then a call to should return 5, a call to should also return 5, and a call to should return 7.
The vectors and are sorted in nondecreasing order. The index is correct, that is, it is between 1 and . Therefore, at least one of the vectors is not empty.
You only need to submit the required procedure; your main program will be ignored.