[C++] No trick, just simple implementation
lcm of an array: we iterate throguh the array and calculate for each position the new lcm, lcm at i will be lcm[i] = lcm(lcm_nums[i-1], nums[i]), since for posi
lcm of an array: we iterate throguh the array and calculate for each position the new lcm, lcm at i will be ```lcm[i] = lcm(lcm_nums[i-1], nums[i])```, since for position i we need only the lcm at ```i-1``` we can keep it in a single variable ```lcm_nums = lcm(lcm_nums, nums[i]);```\ngcf of an array: the same as for LCM, we iterate throguh the array and calculate for each position the new gcd, gcd at i will be ```gcd[i] = gcd(gcd_nums[i-1], nums[i])```, since for position i we need only the gcd at ```i-1``` we can keep it in a single variable ```gcd_nums = gcd(gcd_nums, nums[i]);```\nCalcualte lcm and gcd by eliminating 1 index from nums.We start from -1 simulating that we don\'t eliminated any number from nums.\n# Code\n```cpp []\nclass Solution {\npublic:\n    long long maxScore(vector<int>& nums) {\n        long long result = -1,  gcd_nums = -1, lcm_nums = -1;\n        int n = nums.size();\n        for (int k = -1; k < n; k++) {\n            gcd_nums = -1, lcm_nums = -1;\n            for (int i = 0; i < n; i++) {\n                if (i == k) continue;\n                if (lcm_nums < 0) {\n                    lcm_nums = nums[i], gcd_nums = nums[i];\n                    continue;\n                }\n                gcd_nums = gcd(gcd_nums, nums[i]);\n                lcm_nums = lcm(lcm_nums, nums[i]);\n            }\n            result = max(result, gcd_nums * lcm_nums);\n        }\n        return result;\n    }\n    long long gcd(long long a, long long b) {\n        while(a > 0 && b > 0) {\n            if (a > b) \n                a = a % b;\n            else \n                b = b % a;\n        }\n        return a != 0 ? a : b;\n    }\n    long long lcm(long long a, long long b) {\n        long long ab_gcd = gcd(a, b);\n        return (a / ab_gcd) * b;\n    }\n};\n```
['C++']