You are viewing a single comment's thread. Return to all comments →
Arrays.sort(c); int ans=0; int count=1; int noOfFriendsRem=k; for (int i = c.length-1; i >-1; i--) { if (noOfFriendsRem==0) { noOfFriendsRem=k; count++; } ans+=c[i]*count; noOfFriendsRem--; } return ans;
Seems like cookies are disabled on this browser, please enable them to open this website
Greedy Florist
You are viewing a single comment's thread. Return to all comments →