Two Pointers Speedrun - Two Pointers / Speedrun

https://algo.monster/problems/two-pointers-speedrun

On question 6 (three-sum), on line 11 how do we know to move both the left AND the right pointers? Don’t we need to move just the left to check for more combinations, and then move the right?

If we only moved the left pointer then the only possible combinations left would be duplicates. Say we had nums[left] = -2 and nums[right] = 2 as a valid solution and now we moved left only, nums[left] will either be -2 or larger because of the non-decreasing sorted nature of the array. This means we will end up with duplicates or nums[left] being greater than -2 which guarantees nums[left] + nums[right] > 0.

So we move both pointers to avoid duplicates and ensure we are not only increasing the value of sum.

On question 6. What is the point of the
nums[i] > 0 check on line 5

nvm I get it hehe. Since we sort our anchor number must be at most 0