You are viewing a single comment's thread. Return to all comments →
Simple approach, note (2^j) can be reduced to 1 <<j .
1 <<j
calories.sort(reverse=True) miles = calories[0] for i in range(1, len(calories)): miles += (1<<i)*calories[i] return mile
Seems like cookies are disabled on this browser, please enable them to open this website
Marc's Cakewalk
You are viewing a single comment's thread. Return to all comments →
Simple approach, note (2^j) can be reduced to
1 <<j
.