You are viewing a single comment's thread. Return to all comments →
O(n) sol
def equal(arr): min_value=min(arr) min_operations=math.inf for i in range(5): now_min_operations=0 for x in arr: t=x-min_value now_min_operations+=t//5 t=t% 5 now_min_operations+=t//2 now_min_operations+=t% 2 if now_min_operations<min_operations: min_operations=now_min_operations min_value-=1 return min_operations
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 →
O(n) sol