Two Sum II Sorted Array

1Medium

Two Sum II Sorted Array

Given a 1-indexed sorted array of integers, find two numbers that add up to target. Return their 1-based indices. Use O(1) extra space.

Example 1:

Input: numbers = [2,7,11,15], target = 9 Output: [1,2]

Example 2:

Input: numbers = [2,3,4], target = 6 Output: [1,3]

Example 3:

Input: numbers = [-1,0], target = -1 Output: [1,2]

JR

Jnaneshwara Reddy Satti

Builder · ClearCode

Hi — I'm a 21yo CS grad from India. I built ClearCode while recovering from a surgery, because I genuinely believe DSA should be visual, free, and accessible to everyone. No VC funding. No team. Just me, my laptop, and a lot of chai. ☕

If ClearCode helped you understand even one concept — consider supporting it. Every rupee keeps the servers running and new videos coming.

Support via Razorpay
Support ClearCode ☕
Two Sum II Sorted Array — Medium Two Pointers Algorithm | ClearCode