Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
GoogleCodindQues.py
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
#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)
[
+
]
Show input
edit mode
|
history
|
discussion