We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8917da0 commit e7a1b5eCopy full SHA for e7a1b5e
two-sum/ohkingtaek.py
@@ -0,0 +1,11 @@
1
+class Solution:
2
+ def twoSum(self, nums: List[int], target: int) -> List[int]:
3
+ """
4
+ nums를 앞에서부터 하나씩 보면서 현재 값(nums[i])과 더해서 target이 되는 값이 뒤쪽 배열에 있는지 확인합니다.
5
+ 있으면 그 값의 index를 찾아서 같이 반환합니다.
6
7
+ dp = []
8
+ for i in range(len(nums)):
9
+ if (target - nums[i]) in nums[i+1:]:
10
+ return [i, nums[i+1:].index(target - nums[i]) + i+1]
11
+
0 commit comments