Data Structures19 sections · 729 units
Open in Course

Problem - Two Sum Sorted

Classic two pointers

Given a sorted array of integers and a target sum, find two numbers such that they add up to the target. Return the indices (1-indexed). The array is already sorted.

The sorted property makes two pointers work. If it weren't sorted, you'd need a different approach (like a hash map, which I'll cover later). Read the problem. There's exactly one solution.