Python3 || Two eight-line versions || T/S: 99% / 89%
\n### Brute Force with an optimization version:\nHere\'s the intuition:\n- The problem\'s constraints allow for acceptable O(N^2) solutions.\n\n- The constraint
\n### Brute Force with an optimization version:\nHere\'s the intuition:\n- The problem\'s constraints allow for acceptable *O*(*N*^2) solutions.\n\n- The constraints also permit significant optimization in using *Counter* to filter the elements of `nums` so that we only test the *unique* elements of `nums`.\n\n```python3 []\nclass Solution:\n    def maxScore(self, nums: List[int]) -> int:\n\n        n, ctr = len(nums), Counter(nums)\n\n        mx = gcd(*nums) * lcm(*nums)\n \n        if n > 1:\n\n            for i in range(n):\n                if ctr[nums[i]] > 1: continue\n\n                arr = nums[:i] + nums[i+1:]\n                mx = max(mx, gcd(*arr) * lcm(*arr))\n        \n        return mx\n```\n___\n\n### Prefix version:\n\nHere\'s the intuition:\n\n- We use `accumulate` to build *prefix* lists. \n- We zip these lists and `nums` to facilitate iterating the *lcm-gcd* products.\n- We return the maximum of these products as the answer.\n\n```python3  []\nclass Solution:\n    def maxScore(self, nums: List[int]) -> int:\n\n        n, lcm_, gcd_ = len(nums), 1, 0\n        ans = gcd(*nums) * lcm(*nums)\n\n        pref_lcm = list(accumulate(nums[n-1:0:-1], lcm, initial = 1))[::-1]\n        pref_gcd = list(accumulate(nums[n-1:0:-1], gcd, initial = 0))[::-1]\n\n        for pref_lcm, pref_gcd, num in zip(pref_lcm, pref_gcd, nums):\n            \n            ans = max(ans, lcm(lcm_, pref_lcm) * gcd(gcd_, pref_gcd))\n            lcm_, gcd_ = lcm(lcm_, num), gcd(gcd_, num)\n\n        return ans\n```\n[https://leetcode.com/problems/find-the-maximum-factor-score-of-array/submissions/1435402519/\n](https://leetcode.com/problems/find-the-maximum-factor-score-of-array/submissions/1435402519/\n)\nI could be wrong, but I think that time complexities is *O*(*N*^2) and space complexity is *O*(*N*), in which *N* ~ `len(nums)`.\n
['Python3']