Two pointer
Denotes 2 pointers, left from the start index, right from the end index.
Then, move those 2 indexes to find out the target value
int left = 0, right = N-1;
while(left < right)
{
...
if(...){
left++;
}
else{
right--;
}
}
Last updated
Was this helpful?