I was actually thinking more in the line of:
Let n={3,5,10,15,17} and k=13. 15 and 17 should not be considered at all since they are greater.
The numbers are not supposed to be negative. The worst case remains the same.
But if n is meant to be sorted, we can then only check the left side of n up to the very closest number to k, which is still less than k. That would change the approach in general, I would think.

## re: Java Daily Coding Problem #001 VIEW POST

TOP OF THREAD FULL DISCUSSIONI was actually thinking more in the line of:

Let n={3,5,10,15,17} and k=13. 15 and 17 should not be considered at all since they are greater.

The numbers are not supposed to be negative. The worst case remains the same.

But if n is meant to be sorted, we can then only check the left side of n up to the very closest number to k, which is still less than k. That would change the approach in general, I would think.