By Ahmed Shafique
The "Two Sum" problem is one of the most commonly asked coding questions in technical interviews and is also categorized as an easy-level problem on LeetCode.
The goal is to find two numbers in a given list whose sum equals a specific target value, and return their indices.
Example:
If the target is 10
and the list is [1, 8, 2, 6, 5]
, then the pair of numbers that add up to 10
is 8 + 2
.
The indices of these two numbers are [1, 2]
, so that would be the correct output.