Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update 2592.Maximize Greatness of an Array.cpp #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions LeetCode/2592.Maximize Greatness of an Array.cpp
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
/*
written by Pankaj Kumar.
country:-INDIA
*/
typedef long long ll ;
const ll INF=1e18;
const ll mod1=1e9+7;
const ll mod2=998244353;
//Add main code here

class Solution
{
public:
int maximizeGreatness(vector<int> &nums)
{
int n=nums.size();
vector<pair<int,int>> v1(n);
vector<int> v1(n);
vector<int> v2(n);
int count=0;

for(int i=0;i<n;i++){
v1[i]={nums[i],i};
v2[i]=nums[i];
v1[i]=nums[i];
}
sort(v2.begin(),v2.end());

sort(v1.begin(),v1.end());
v2 = v1;

int pos=0;

for(int i=0;i<n;i++){
while(pos<n && v1[i].>=firstv2[pos]){
while(pos<n && v1[i] >=v2[pos]){
pos++;
}
if(pos<n){
Expand All @@ -40,4 +37,4 @@ class Solution
return count;

}
};
};