Created
April 9, 2018 12:08
-
-
Save philangist/70fca61d2d124f773830b39be8eca823 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Examples: | |
Input: {5, 20, 3, 2, 50, 80}, n = 78 | |
Output: Pair Found: (2, 80) | |
Input: {90, 70, 20, 80, 50}, n = 45 | |
Output: No Such Pair | |
""" | |
def find_diff(arr, n): | |
for i in arr: | |
if (i + n) in arr: | |
return (i, i + n) | |
return "No Such Pair" | |
arr = {5, 20, 3, 2, 50, 80} | |
n = 78 | |
find_diff(arr, n) | |
arr = {90, 70, 20, 80, 50} | |
n = 45 | |
find_diff(arr, n) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment