class Solution:
    def twoSum(self, nums: List[int], target: int) -> List[int]:
        for i in range(0, len(nums) - 1):
            for j in range(i+1, len(nums)):
                if nums[i] + nums[j] == target:
                    return[i, j]
class Solution:
    def twoSum(self, nums: List[int], target: int) -> List[int]:
        found = {}
        for i, n in enumerate(nums):
            complement = target - n
            if complement in found:
                return [found[complement], i]
            found[n] = i

Add refactored O(n) solution