Wenhe Qi

Feb 4, 2021

3 min read

LeetCode Explained: 1 Two Sum

In this question, we are given an array of integer nums and an integer target, and we are asked to return two distinct indices such that the numbers in those positions add up to be the target. The question assumes that there is one and only one solution for each input.

Approach 1: Brute Force

For example: