Are all pairs considered?

How can one be sure that all pairs have been considered?

Hello @rbak we are sure about this as we have created the range.
after sorting as if the sum is greater then we are sure that we have to decrement the right pointer and vice versa.

Can you please explain in more detail? I am not able to understand.

@rbak see if there is one array and if we sort the elements so the array is 1 2 3 4 5 6.
and the target is 4 so we will make 2 pointers one from the start and one from the end
so lets suppose the we have 1 with us and 6 from the array then we will see if their sum is greater then the target then we will decrement the right pointer because the number after it will always give us sum greater then target and just like this only if the sum is less then the target then we will increment the left pointer because after the number at left pointer the possibility to get sum will be increased as the numbers are already sorted.