Two Sum
Easy
Arrays
Given an array of integers nums and an integer target, find the two numbers whose sum equals target and print their indices. Exactly one valid pair exists and the same element cannot be used twice. Print the smaller index first.
Constraints
2 <= n <= 10^5 -10^9 <= nums[i], target <= 10^9 Exactly one solution exists
Discussion
No discussions yet.
Join Shalyam Newsletter
Get exclusive insights with every issue: education, research and innovation news.
Shalyam Support
Hi! Ask us anything — we'll reply on WhatsApp or Telegram within 24 hours.