Math Fundamentals18 sections · 814 units
Open in Course

Problem - Two Sum

LeetCode 1

Given an array of integers numsnums and a target integer targettarget, find two indices ii and jj such that nums[i]+nums[j]=targetnums[i] + nums[j] = target.

For example, if nums=[2,7,11,15]nums = [2, 7, 11, 15] and target=9target = 9, the answer is indices [0,1][0, 1] because 2+7=92 + 7 = 9.

This is a classic problem that demonstrates algebraic thinking. Before reading on, think: what are you looking for? You need two numbers that add to the target.