Simple Python solution | Beats 100% in time and memory
Intuition\nThe GCD of multiple numbers can be computed by taking the GCD of the first two, then repeating with the next number:\n\nGCD(a, b, c, ...) = GCD(GCD(a
# Intuition\nThe GCD of multiple numbers can be computed by taking the GCD of the first two, then repeating with the next number:\n\n$$GCD(a, b, c, ...) = GCD(GCD(a, b), c, ...)$$\n\nThe same thing is true for the LCM:\n\n$$LCM(a, b, c, ...) = LCM(LCM(a, b), c, ...)$$\n\nTo get the LCM of two numbers, we can multiply them and divide by their GCD.\nTo get the GCD of two numbers, we can use the [Eucledian algorithm](https://en.wikipedia.org/wiki/Euclidean_algorithm).\n\n\n# Approach\nRemove each number in the array, and compute the resulting score each time. Store the max score in a variable. Also compute the score of the array without removing numbers.\n\n# Code\n```python3 []\nclass Solution:\n    def maxScore(self, nums: List[int]) -> int:\n        if len(nums) == 1: return nums[0] ** 2\n\n        def gcd_all(nums):\n            def gcd(a, b):\n                if a is None or b is None:\n                    # This handles the None that replaces a removed number\n                    return a or b\n                if b == 0:\n                    return a\n                return gcd(b, a % b)\n            return reduce(gcd, nums)\n\n        def lcm_all(nums):\n            def lcm(a, b):\n                if a is None or b is None:\n                    # This handles the None that replaces a removed number\n                    return a or b\n                return (a * b) // gcd(a, b)\n            return reduce(lcm, nums)\n\n        def get_score(nums):\n            return gcd_all(nums) * lcm_all(nums)\n\n        nums.append(None)  # To test the whole array without removing any numbers\n        max_score = 0\n        for i in range(len(nums)):\n            # Remove current number\n            temp = nums[i]\n            nums[i] = None\n\n            max_score = max(max_score, get_score(nums))\n\n            # Put it back\n            nums[i] = temp\n\n        return max_score\n\n```\n\n# Test cases\n```\n[2,4,8,16]\n[1,2,3,4,5]\n[3]\n[10,18,16]\n[15,30]\n[1,13,28]\n[17,25,20,30,11,13]\n```
['Python3']