Sorted Two Sum

L2 Easy Arrays & Hashing
Concept
For a sorted array, the two-pointer dance is elegant: sum too small means move the left pointer right, sum too large means move the right pointer left.
The array nums is sorted from smallest to largest. Return true if two different entries add up to target, and false otherwise.
Examples
▸ nums = [-3, 0, 1, 2, 4], target = 1
→ true
▸ nums = [1, 2, 3], target = 7
→ false
▸ nums = [], target = 5
→ false
Progressive Hints
Hint 1 · Nudge
Sorted order lets you shrink the search window instead of checking everything.
Hint 2 · Plan
Put one pointer at the start and one at the end. If their sum equals target, return true. If the sum is too small, move the left pointer right; if too large, move the right pointer left. If the pointers meet, return false.
Hint 3 · Approach
left = 0, right = last index. While left < right: if nums[left] + nums[right] == target return true; if the sum is too small, left = left + 1; else right = right - 1. Return false.
Output
// Run your code to see the output here.