Apple and Orange (hackerrank) Problem Statement.
Solution :-.
def countApplesAndOranges(s, t, a, b, apples, oranges):
apple1=[]
oranges1=[]
countapple=0
countorange=0
apple1=[x + a for x in apples]
oranges1=[y + b for y in oranges]
for j in apple1:
if(j>=s and j<=t):
countapple+=1
for p in oranges1:
if(p<=t and p>=s):
countorange+=1
print(countapple)
print(countorange)
Solution :-.
def countApplesAndOranges(s, t, a, b, apples, oranges):
apple1=[]
oranges1=[]
countapple=0
countorange=0
apple1=[x + a for x in apples]
oranges1=[y + b for y in oranges]
for j in apple1:
if(j>=s and j<=t):
countapple+=1
for p in oranges1:
if(p<=t and p>=s):
countorange+=1
print(countapple)
print(countorange)

0 Comments