Hint, Solution & Code(C++)

Hint: Binary search!!

Solution: This is a pretty easy binary search problem. All we need is to check for every number of the second list(as first list is sorted in ascending order) let's denote as x, if we can find y = 10000-x in the first list. If we find y for any x(from the 2nd list) then we will print "YES". Because we already got a pair x, y for which x + y = 10000.

So, the complexity is NlogN(as we are doing binary search for every element of a list in the worst case).

[Code was deleted]

*Edited by moderator 06.06.2021 03:06*

Re: Hint, Solution & Code(C++)

Binary search is not needed here. It is enough to traverse the array with two pointers.