A customer wants to pay exactly target rupees by buying two items from a menu. The list nums holds the price of every item (a price can be negative, like a discount item).
Find the two items whose prices add up to target, and return their positions (indices) in the list. Each item can be used only once. Every input has exactly one correct pair.
You may return the two indices in any order.
Examples
Example 1:
Input: nums = [8,3,12,5], target = 17
Output: [2,3]
Explanation: The prices at positions 2 and 3 are 12 and 5, and 12 + 5 = 17.
Example 2:
Input: nums = [4,9,6], target = 10
Output: [0,2]
Explanation: The first and last prices are 4 and 6, and 4 + 6 = 10.
Example 3:
Input: nums = [6,6,1], target = 12
Output: [0,1]
Explanation: Two items can have the same price. They are still two different positions.