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 cutTheSticks(arr):
# Write your code here
list2=[]
while arr:
allcount=0
cut_s=min(arr)
for i in range(len(arr)):
allcount+=1
arr[i]=arr[i]-cut_s
list2.append(allcount)
while True:
if 0 in arr:
arr.remove(0)
else:
break
return list2
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Cut the sticks
You are viewing a single comment's thread. Return to all comments →
def cutTheSticks(arr): # Write your code here list2=[] while arr: allcount=0 cut_s=min(arr) for i in range(len(arr)): allcount+=1 arr[i]=arr[i]-cut_s list2.append(allcount) while True: if 0 in arr: arr.remove(0) else: break return list2