We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Algorithms
- Greedy
- Marc's Cakewalk
- Discussions
Marc's Cakewalk
Marc's Cakewalk
Sort by
recency
|
436 Discussions
|
Please Login in order to post a comment
c++ answer------- long marcsCakewalk(vector calorie) { sort(calorie.begin(),calorie.end(),greater()); long miles=0; for(int i=0;i
Here is my c++ solution, you can watch explanation here : https://youtu.be/RRJoL2vDmZM
include
using namespace std; int main(){ long int n; cin >> n; long long int p = 0; int arr[n]; for(int i = 0; i < n; i++){ cin >> arr[i]; }
}
My Java solution with o(n log n) time complexity and o(1) space complexity: