我是python的新手,它试图在python中实现一个hashmap来解决两次求和leet代码的问题,但是这里有些错误
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
d = {}
for i in range(len(nums)):
d.update({nums[i]: i})
for j in range(len(nums)):
if (target - nums[j]) in d:
return [j, d.get(target-nums[j])]