19주차 3/10

전체 17/150

O(N^2) 로 풀었다. 

다음에는 O(N)으로 풀자..ㅎㅎ

class Solution:
    def twoSum(self, nums: List[int], target: int) -> List[int]:
        ans = []
        for i in range(len(nums)):
            for j in range(i+1, len(nums)):
                if(nums[i] + nums[j] == target):
                    ans.append(i)
                    ans.append(j)
                    print(ans)
                    return ans

Posted by 공놀이나하여보세
,