Tips

two porinters pattern

complex solution will like this:

while (l < r) { // global while
    while (l < r && xxx ) {
        //in internal while loop, keep check and skip some elements
    }
    l++;
    r--;
}

Last updated