Given an array of integers nums and an integer target, find two indices i and j such that
nums[i]+nums[j]=target. You may assume that each input has exactly one solution, and you
may not use the same element twice.
Input / Output
Input: An array nums of n integers and an integer target.
Output: Two indices i,j with i=j such that nums[i]+nums[j]=target.
Constraints
2≤n≤104,−109≤nums[i]≤109
Step 1 / 10
Step 1 / 10
We want to find two numbers that sum to target=9. We use the brute-force approach: try every pair (i,j) with i<j.
Step 2 / 10
Outer loop: set i=0. The value at index 0 is nums[0]=2.