Hi,

Given a sorted array and K number of elements that sum to given N. write the code using twoSum given.

The solution for this is given in this article http://lifexplorer.me/leetcode-3sum-4sum-and-k-sum/

I am using this as the reference and I don't have any contribution to it, I am learning from it.

In the second solution, we keep decrementing K-1 up to K=2 and then compute twoSum function.

Now my question is, we need to find K elements any where in the array.

a) Last two elements will be located anywhere in the array, but the first K-2 elements will be in the same sequence right ?.

How is this solution working?.

I am not able to understand how this is working, Could some one please explain ?