Skip to content

Commit c3e20ba

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent d48e8a3 commit c3e20ba

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

interview-bootcamp/Two-Sum.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
def to_sum(nums, target):
22
"""
33
This function finds two numbers in the list 'nums' that add up to 'target'.
4-
4+
55
:param nums: List of integers
66
:param target: Integer target sum
77
:return: Tuple of the two numbers that add up to target, or None if no such pair exists
88
"""
99
num_set = set()
10-
10+
1111
for num in nums:
1212
complement = target - num
1313
if complement in num_set:
1414
return (complement, num)
1515
num_set.add(num)
16-
16+
1717
return None
1818

19+
1920
if __name__ == "__main__":
20-
print(to_sum([2, 7, 11, 15], 9))
21+
print(to_sum([2, 7, 11, 15], 9))

0 commit comments

Comments
 (0)