class Solution: # @return a tuple, (index1, index2) def twoSum(self, num, target): dict={} for i in range(len(num)): res=target-num[i] if res in dict: return (dict[res],i+1) else: dict[num[i]]=i+1 return (-1,-1)
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment