We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
def countApplesAndOranges(s, t, a, b, apples, oranges):
house_range = range(s,t+1)
valid_apples, valid_oranges = 0,0
for i in apples:
if i + a in house_range:
valid_apples += 1
for j in oranges:
if j + b in house_range:
valid_oranges += 1
print valid_apples
print valid_oranges
Why is using for loop like this so much slower than the solution presented by @navjotahuja92? It is also using for loop and an if condition within it.
Apple and Orange
You are viewing a single comment's thread. Return to all comments →
Why is using for loop like this so much slower than the solution presented by @navjotahuja92? It is also using for loop and an if condition within it.