From 9a6cbbebf546fe789e31efbb7c986d79554e6cce Mon Sep 17 00:00:00 2001 From: Manish Arya <88669366+Manish989927@users.noreply.github.com> Date: Sat, 18 Mar 2023 23:17:18 +0530 Subject: [PATCH] Update 2592.Maximize Greatness of an Array.cpp --- .../2592.Maximize Greatness of an Array.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/LeetCode/2592.Maximize Greatness of an Array.cpp b/LeetCode/2592.Maximize Greatness of an Array.cpp index 79aff33..0deeb7f 100644 --- a/LeetCode/2592.Maximize Greatness of an Array.cpp +++ b/LeetCode/2592.Maximize Greatness of an Array.cpp @@ -1,12 +1,7 @@ -/* - 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 { @@ -14,19 +9,21 @@ class Solution int maximizeGreatness(vector &nums) { int n=nums.size(); - vector> v1(n); + vector v1(n); vector v2(n); int count=0; + for(int i=0;i=firstv2[pos]){ + while(pos=v2[pos]){ pos++; } if(pos