Skip to content

Instantly share code, notes, and snippets.

@therealnaveenkamal
Created April 28, 2021 16:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save therealnaveenkamal/665e957a473595efe4e41157a81b2f14 to your computer and use it in GitHub Desktop.
Save therealnaveenkamal/665e957a473595efe4e41157a81b2f14 to your computer and use it in GitHub Desktop.
Daily Coding Problem #1
def checkFunc(k, input_nums):
for i in range(len(input_nums)):
for j in range(i+1,len(input_nums)):
if(input_nums[i] + input_nums[j] == k):
return True
return False
input_nums = list(map(int, input().split(" ")))
k = int(input())
print(checkFunc(k, input_nums))
@therealnaveenkamal
Copy link
Author

Question: Given a list of numbers and a number k, return whether any two numbers from the list add up to k.
For example, given [10, 15, 3, 7] and k of 17, return true since 10 + 7 is 17.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment