Run Code
|
API
|
Code Wall
|
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
PyRegBackRef
test1.py
exception handling from user
Introduce myself
Game4
My cousin asked for this will never forgive her
python_study_note_for loop@nested loop
Page 353 ex 42
reverse the number
new traceback.py