• + 0 comments

    This is my c++ solution of this problem, you can watch the explanation here : https://youtu.be/jZPhE_MTkVg

    vector<int> cutTheSticks(vector<int> arr) {
        sort(arr.begin(), arr.end());
        vector<int>result(1, arr.size());
        for(int i = 1; i < arr.size(); i++){
          if(arr[i-1] != arr[i]) result.push_back(arr.size() - i);
        }
        return result;
    }