Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
What if we have the array sorted?
Loop the array and get the value A[i] then we need to find a value A[j] such that A[i] + A[j] < K which means A[j] < K - A[i]. In order to do that we can find that value with a binary search.