728x90
https://leetcode.com/problems/two-sum/submissions/938964500/
유형 : Brute Force
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
answer = []
# index 를 담아서 리턴한다
N = len(nums)
for i in range(N-1):
for j in range(i+1, N):
if nums[i] + nums[j] == target:
answer.append(i)
answer.append(j)
return answer
728x90
'Algorithm (PS)' 카테고리의 다른 글
[Programmers] 더 맵게 - Python (0) | 2023.05.20 |
---|---|
[leetcode] longest substring without repeating characters (0) | 2023.05.15 |
[프로그래머스] 카펫 (Python) - 완전탐색/Brute Force (0) | 2023.04.06 |
[백준] 10655번: 마라톤 1 (0) | 2023.03.27 |
[프로그래머스] 구명보트 Python (0) | 2023.03.25 |