what is wrong with following code:
Two pointer approach
it is giving wrong answer
the problem in your code is that you are printing a[i] and a[j] after incrementing i and decrementing j which should 'nt be the case
instead of
if(currentsum == k){
i++;
j--;
cout<<a[i]<<" "<<a[j]<<endl;
}
it should be
if(currentsum == k){
cout<<a[i]<<" "<<a[j]<<endl;
i++;
j--;
}