0% found this document useful (0 votes)
2 views2 pages

LCB Rk7fdz

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

LCB Rk7fdz

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

#define ll long long

class Solution {

public:

int maximumLength(vector<int>& nums) {

std::map<ll, ll> mp, mp2;

for (ll a : nums) {

mp[a]++;

ll cc = mp[1];

if (cc % 2 == 0) {

cc--;

ll mx = 1;

for (auto& a : mp) {

ll c = 1;

if (a.second > 1) {

c = 2;

ll k = a.first * a.first;

mp.erase(a.first);

while (mp[k] > 1) {

mp[k] = 0;

c += 2;

k = k * k;
}

if (mp[k] == 1) {

mp[k] = 0;

c++;

} else {

c--;

mx = std::max({c, mx, cc});

return mx;

};

You might also like