Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8586bcf

Browse files
author
Amogh Singhal
authored
Create find_pairs_sum_k.py
1 parent 77e54f9 commit 8586bcf

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

‎find_pairs_sum_k.py‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
def find_pairs(num_array, k):
2+
pairs_array = []
3+
for num in num_array:
4+
if (k-num) in num_array:
5+
pairs_array.append((num, (k-num)))
6+
return pairs_array
7+
8+
result = find_pairs([0, 14, 0, 4, 7, 8, 3, 5, 7], 11)
9+
print(result)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /