You are viewing a single comment's thread. Return to all comments →
Here is my c++ solution, you can watch explanation here : https://youtu.be/RRJoL2vDmZM
long marcsCakewalk(vector<int> calorie) { sort(calorie.begin(), calorie.end(), [](int l, int r){return l > r;}); long ans = 0; for(int i = 0; i < calorie.size(); i++){ ans += pow(2, i) * calorie[i]; } return ans; }
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 →
Here is my c++ solution, you can watch explanation here : https://youtu.be/RRJoL2vDmZM