Solve a LeetCode easy problem in no more than 30 minutes.
Implement two_sum(nums, target) to return the indices of two distinct elements whose values add up to target. Return the indices in any order. Each input has exactly one valid solution.
Input: an integer list nums and integer target. Output: a list containing the two zero-based indices.
Constraints: 2 <= len(nums) <= 10^4; values and target are between -10^9 and 10^9.
def two_sum(nums, target):