Write a function to implement the two-sum problem.
Given an integer array nums and integer target, return the indices of two distinct elements whose values add up to target. Assume exactly one solution exists, and return the indices in ascending order.
Implement two_sum(nums, target). Return a list containing the two zero-based indices.
def two_sum(nums, target):