- 7-8 PM
SCI H305
Coding Club
- 6:30-7:30 PM
SCI L043
About
nums
and an integer target
, return indices of the two numbers such that they add up to target
.
You may assume that each input would have exactly one solution, and you may not use the same element twice.Python:
def twoSum(self, nums, target): d = {} for i, n in enumerate(nums): m = target - n if m in d: return [d[m], i] else: d[n] = i
Enrich Wellesley community's Computer Science experience beyond the CS curriculum.
For more information, please follow Wellesley CS Club on Facebook.