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.
Hi Zhassan,
can you please look into my code and say where i am doing wrong (apart from time complexity),
t1 = 1
t3 = 3
t5 = 5
for _ in range(int(input().strip())):
l = int(input().strip())
c = [int(f) for f in input().strip().split(' ')]
e = 0
count = 0
while(max(c)!=min(c)):
count += 1
mi = min(c)
mx = max(c)
d = mx-mi
if d >= t1 and d < t3:
e = t1
elif d >= t3 and d < t5:
e = t3
elif d >= t5:
e = t5
for i in range(len(c)):
if c[i] != mx:
c[i]+=e
print(count)
#print(c)
my answer - 933
expected - 10605
but still all are having same numbers of chocolates.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Equal
You are viewing a single comment's thread. Return to all comments →
Hi Zhassan, can you please look into my code and say where i am doing wrong (apart from time complexity),
t1 = 1 t3 = 3 t5 = 5 for _ in range(int(input().strip())): l = int(input().strip()) c = [int(f) for f in input().strip().split(' ')] e = 0 count = 0 while(max(c)!=min(c)): count += 1 mi = min(c) mx = max(c) d = mx-mi if d >= t1 and d < t3: e = t1 elif d >= t3 and d < t5: e = t3 elif d >= t5: e = t5 for i in range(len(c)): if c[i] != mx: c[i]+=e print(count) #print(c)
my answer - 933 expected - 10605 but still all are having same numbers of chocolates.