You are viewing a single comment's thread. Return to all comments →
vector <int> cutTheSticks(vector <int> arr) { // Complete this function vector<int>result; int size = arr.size(); sort(arr.begin(), arr.end()); for (int i=0; i<size; i++) { if (!arr[i]) continue; int cut=0; int val = arr[i]; for (int j=i; j<size; j++) { if (arr[j]) { arr[j] = arr[j] - val; cut++; } } result.push_back(cut); } return result;
}
Seems like cookies are disabled on this browser, please enable them to open this website
Cut the sticks
You are viewing a single comment's thread. Return to all comments →
}