Simple Java Solution
Intuition\n Describe your first thoughts on how to solve this problem. \nBrute force, find the gcd and lcm of the array\nand compare when one element is removed
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nBrute force, find the gcd and lcm of the array\nand compare when one element is removed\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```java []\nclass Solution {\n    public long maxScore(int[] nums) {\n        //edge case\n        if (nums.length == 1) {\n            return(long) nums[0] * nums[0];\n        }\n        long initialGCD = gcdOfArray(nums, -1);\n        long initialLCM = lcmOfArray(nums, -1);\n        long maxScore = initialGCD * initialLCM;\n\n        for (int i = 0; i < nums.length; i++) {\n            long gcd = gcdOfArray(nums, i);\n            long lcm = lcmOfArray(nums, i);\n            long currentScore = gcd * lcm;\n            maxScore = Math.max(currentScore, maxScore);\n        }\n\n        return maxScore;\n    }\n\n    private long gcd(long a, long b) {\n        //base case\n        if (b == 0) return a;\n        return gcd(b, a % b);\n    }\n\n    private long lcm(long a, long b) {\n        //formula based\n        return (a * b) / gcd(a, b);\n    }\n\n    private long gcdOfArray(int[] arr, int exclude) {\n        long result = -1;\n\n        for (int i = 0; i < arr.length; i++) {\n            if (i == exclude) continue;//skip\n\n            if (result == -1) {\n                result = arr[i];\n            } else {\n                result = gcd(result, arr[i]);\n            }\n        }\n\n        return result;\n    }\n\n    private long lcmOfArray(int[] arr, int exclude) {\n        long result = -1;\n        for (int i = 0; i < arr.length; i++) {\n            if (i == exclude) continue;\n            if (result == -1) {\n                result = arr[i];\n            } else {\n                result = lcm(result, arr[i]);\n            }\n        }\n        return result;\n    }\n\n}\n```
['Java']