Skip to content

Commit d935858

Browse files
authored
Merge pull request #3 from htudu/hambira
sub array problem
2 parents 0b90691 + 6e0a8d6 commit d935858

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

hambira/find_sub_list_of_sum.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
'''
2+
Given a list of numbers, find the possible list of 2 numbers with a provided sum
3+
'''
4+
5+
s = 7
6+
nums = [1, 6, 4, 7, 2, 8, 9, 3, 2, 4]
7+
8+
def find_list(org_nums, sum):
9+
for i in org_nums:
10+
x = sum - i
11+
if x in org_nums:
12+
return [i,x]
13+
14+
print(find_list(nums, s))

0 commit comments

Comments
 (0)