Beats 100%
Intuition\n Describe your first thoughts on how to solve this problem. \nFirst calculate the product of GCDLCM of the whole array then calculate all other possi
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nFirst calculate the product of GCD*LCM of the whole array then calculate all other possible products excluding 1 element per iteration.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n- Generate GCD*LCM of full array\n- Now iterate accross whole array.\n    - Using another loop, excelude 1 element per iteration to check the new product obtained and return the maximum of all such products.\n# Complexity\n- Time complexity:- $O(n^2)$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:- $O(1)$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    long long __gcd(long long a,long long b)\n    {\n        if(b==0)\n            return a;\n        return __gcd(b,a%b);\n    }\n    long long maxScore(vector<int>& nums) {\n        if(nums.size()==1)\n            return nums[0]*nums[0];\n        sort(nums.begin(),nums.end());\n        long long gcd=nums[0],lcm=nums[0];\n        for(int i=1;i<nums.size();++i)\n        {\n            gcd=__gcd(gcd,(long long)nums[i]);\n            lcm=(lcm*nums[i])/__gcd(lcm,(long long)nums[i]);\n        }\n        long long ans=gcd*lcm;\n        for(int i=0;i<nums.size();++i)\n        {\n            long long g=-1; \n            long long l=1; \n            for(int j=0;j<nums.size();++j) \n            { \n                if(i==j) \n                    continue;  \n                if(g==-1) \n                    g=nums[j]; \n                else \n                    g=__gcd(g,nums[j]);\n                l=(l*nums[j])/__gcd(l,(long long)nums[j]);\n            } \n            long long curr=g*l; \n            ans=max(ans,curr);\n        }\n        //cout<<a<<" "<<b<<"\\n";\n        return ans;\n    }\n};\n```
['Greedy', 'Number Theory', 'C++']