ขนาดวิดีโอ: 1280 X 720853 X 480640 X 360
แสดงแผงควบคุมโปรแกรมเล่น
เล่นอัตโนมัติ
เล่นใหม่
class Solution: def twoSum(self, nums: List[int], target: int) -> List[int]: dict_of_seen_values = {} for idx, value in enumerate(nums): required_number = target - value if required_number in dict_of_seen_values: return [idx, dict_of_seen_values[required_number]] else: dict_of_seen_values[value] = idx
Thanks sir
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
dict_of_seen_values = {}
for idx, value in enumerate(nums):
required_number = target - value
if required_number in dict_of_seen_values:
return [idx, dict_of_seen_values[required_number]]
else:
dict_of_seen_values[value] = idx
Thanks sir