Two Sum

Easy

Given nums: list[int] and target: int, return the indices of two distinct elements of nums whose values add to target as list[int], smaller index first. Return [] when no such pair exists. nums contains between 2 and 100000 integers, and every element and target is between -1000000000 and 1000000000 inclusive. Duplicate values are allowed. At most one pair of indices sums to target.

Examples
input    nums = [2, 7, 11, 15], target = 9
output   [0, 1]
input    nums = [3, 2, 4], target = 6
output   [1, 2]
python3