Skip to content

Commit 488b374

Browse files
committed
Runtime: 97 ms (Top 46.27%) | Memory: 76.00 MB (Top 96.77%)
1 parent a4321a8 commit 488b374

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Runtime: 97 ms (Top 46.27%) | Memory: 76.00 MB (Top 96.77%)
2+
3+
class Solution {
4+
public:
5+
int maximizeGreatness(vector<int>& nums) {
6+
sort(nums.begin(),nums.end());
7+
int n=nums.size();
8+
int ans=0;
9+
int ind=n-1;
10+
for(int i=n-2;i>=0;i--)
11+
{
12+
if(nums[i]<nums[ind])
13+
{
14+
ind--;
15+
ans++;
16+
}
17+
}
18+
return ans;
19+
}
20+
};

0 commit comments

Comments
 (0)