I have recieve as input a list of candidates for work so that the list I recieve is already sorted by requirments of the salary for each one and also is grase from the university(this parameter is not sorted). example:
danny 13000$ 75.56
dan 9000$ 100
bob 5000$ 98
in such a list I need to find the two candidates with the higher grades so that sum of both salary is not more than 10000$ (I can assume their is no two candidates with the same grade and there are no two pair of students with the same sum of grade (94+90 = 91 + 93))
I need to find them in comlexity of O(n).
I understand I can not do a sort algorithm (the min is n*log(n)) so How can I do that ?
is it possible ?