def two_sum_dict(arr, target):
    """
    Increase speed by using dictionary.

    :Time: O(n)
    :Space: O(n)
    """
    re = {}
    for i in range(len(arr)):
        re[arr[i]] = i

    for i in range(len(arr)):
        diff = target - arr[i]
        if diff in re:
            return [i, re[diff]]