python: leetcode - 1 Two Sum
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
value_container = {}
for index, value in enumerate(nums):
left_value = target - value
if value in value_container:
return [value_container[value], index]
value_container[left_value] = index
相關文章
- Leetcode 1 two sumLeetCode
- LeetCode | 1 Two SumLeetCode
- LeetCode-1 Two SumLeetCode
- [LeetCode]1.Two SumLeetCode
- LeetCode #1:Two Sum(簡單題)LeetCode
- python leetcode 之兩數之和(two sum)PythonLeetCode
- LeetCode: Two sum(兩數之和)LeetCode
- leetcode 371. Sum of Two IntegersLeetCode
- LeetCode Two Sum(001)解法總結LeetCode
- 【Leetcode】167. Two Sum II - Input array is sortedLeetCode
- 1.兩數之和 Two Sum
- LeetCode 之 JavaScript 解答第一題 —— 兩數之和(Two Sum)LeetCodeJavaScript
- 力扣.1 兩數之和 N 種解法 two-sum力扣
- 653-Two Sum IV - Input is a BST
- leetcode Sum系列LeetCode
- Leetcode Path SumLeetCode
- 001-ksum 求符合條件的 k 個數 1. Two Sum/15. 3Sum/18. 4Sum/
- 001,Two Sum(求兩數的和)
- Leetcode 231 Power of TwoLeetCode
- Leetcode 39 Combination SumLeetCode
- abc098D Xor Sum 2(two point)
- Leetcode 29 Divide Two IntegersLeetCodeIDE
- LeetCode 2 Add Two NumbersLeetCode
- LeetCode | 349 Intersection Of Two ArraysLeetCode
- Leetcode 231. Power of TwoLeetCode
- leetcode-39-Combination SumLeetCode
- Leetcode 40 Combination Sum IILeetCode
- Leetcode 15 3SumLeetCode
- Leetcode 18 4SumLeetCode
- LeetCode 112. Path SumLeetCode
- leetcode-29. Divide Two IntegersLeetCodeIDE
- LeetCode-2 Add Two NumbersLeetCode
- Leetcode 21 Merge Two Sorted ListsLeetCode
- [LeetCode] 29. Divide Two IntegersLeetCodeIDE
- Leetcode 4 Median of Two Sorted ArraysLeetCode
- LeetCode 2. Add Two NumbersLeetCode
- 【Leetcode】1029. Two City SchedulingLeetCode
- [LeetCode] 523. Continuous Subarray SumLeetCode