Skip to content

Commit 73f160f

Browse files
Add files via upload
My 1st commit
1 parent e7fffd6 commit 73f160f

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

‎my_codes/sum_pair.py‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
def pair_sum(arr, k):
3+
4+
if len(arr) < 2:
5+
return "Too small array"
6+
7+
seen = set()
8+
output = set()
9+
10+
for num in arr:
11+
d = k - num
12+
if d not in seen:
13+
seen.add(num)
14+
else:
15+
output.add((num,d))
16+
17+
return output
18+
19+
a = [1,3,2,2]
20+
print(pair_sum(a, 4))
21+

0 commit comments

Comments
 (0)