mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-09 19:44:45 +08:00
@ -163,7 +163,7 @@ class Solution:
|
|||||||
for index, value in enumerate(nums):
|
for index, value in enumerate(nums):
|
||||||
if target - value in records: # 遍历当前元素,并在map中寻找是否有匹配的key
|
if target - value in records: # 遍历当前元素,并在map中寻找是否有匹配的key
|
||||||
return [records[target- value], index]
|
return [records[target- value], index]
|
||||||
records[value] = index # 遍历当前元素,并在map中寻找是否有匹配的key
|
records[value] = index # 如果没找到匹配对,就把访问过的元素和下标加入到map中
|
||||||
return []
|
return []
|
||||||
```
|
```
|
||||||
(版本二)使用集合
|
(版本二)使用集合
|
||||||
|
Reference in New Issue
Block a user