3334.Find the Maximum Factor Score of Array (Solution)
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```python []\nfrom functools import reduce\ndef gcd(a, b):\n    while b:\n        a, b = b, a % b\n    return a\n\ndef lcm(a, b):\n    return a * b // gcd(a, b)\n\ndef array_gcd(nums):\n    return reduce(gcd, nums)\n\ndef array_lcm(nums):\n    return reduce(lcm, nums)\n\nclass Solution:\n    def maxScore(self, nums):\n        if len(nums) == 1:\n          \n            return nums[0] * nums[0]\n        \n        full_gcd = array_gcd(nums)\n        full_lcm = array_lcm(nums)\n        max_score = full_gcd * full_lcm \n        \n        for i in range(len(nums)):\n            remaining_nums = nums[:i] + nums[i+1:]\n            \n            current_gcd = array_gcd(remaining_nums)\n            current_lcm = array_lcm(remaining_nums)\n            \n            current_score = current_gcd * current_lcm\n            max_score = max(max_score, current_score)\n        \n        return max_score\n\nsol = Solution()\nprint(sol.maxScore([2, 4, 8, 16])) \nprint(sol.maxScore([1, 2, 3, 4, 5])) \nprint(sol.maxScore([3])) \n\n```
['Python']