Marc's Cakewalk

  • + 0 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;
    }