Greedy with prefix array | 4 ms - beats 100.00%
Complexity\n- Time complexity: O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(n)\n Add your space complexity here, e.g. O(n) \n\n# Co
# Complexity\n- Time complexity: $$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(n)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```python3 []\nfrom math import lcm, gcd\n\nclass Solution:\n    def maxScore(self, nums: List[int]) -> int:\n        suffixes = []\n        l, g = 1, 0\n        for elem in reversed(nums):\n            suffixes.append((l, g))\n            l = lcm(l, elem)\n            g = gcd(g, elem)\n            \n        result = l * g\n        l, g = 1, 0\n\n        for i, elem in enumerate(nums):\n            prefix_l, prefix_g = suffixes.pop()\n            result = max(\n                result,\n                lcm(l, prefix_l) * gcd(g, prefix_g),\n            )\n            l = lcm(l, elem)\n            g = gcd(g, elem)\n        \n        return result\n```
['Greedy', 'Suffix Array', 'Python3']