Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
GoogleCodindQues.py
#python 3.5.2 #This problem was recently asked by Google. #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. #Bonus: Can you do this in one pass?*/ b=fun(235,10,15,3,7) print(b) def fun(key,list): i=0 while i<len(list)-1: j=len(list)-1 temp=list[i] while j>i: if temp+list[j]==key: return True j-=1 i+=1 return False b=fun(235,[10,15,3,7]) print(b)
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
Add missing names
Achinta
L4-HW final
Byear
afw
Lesson 7 part 2
raja praja
ConstructorBehaviourInInheritance
Ex1
Lawrence.py
Please log in to post a comment.