Beats 100% in both Time and Space || Simplest Approach to understand
Complexity\n- Time complexity:\n    \uD835\uDC42(n^2)\n\n- Space complexity:\n    O(n)\n\n\n# Code\njava []\nclass Solution {\n    public long maxScore(int[] nu
# Complexity\n- Time complexity:\n    \uD835\uDC42(n^2)\n\n- Space complexity:\n    O(n)\n\n\n# Code\n```java []\nclass Solution {\n    public long maxScore(int[] nums) {\n        int n = nums.length;\n        if(n==0) return 0;\n        if(n==1) return (long)(nums[0] * nums[0]);\n        long maxans = lcmarr(nums) * gcdarr(nums);\n        for(int i =0 ; i<n; i++){\n            int[] newarr = new int[n-1];\n            int k =0;\n            for(int j =0 ; j<n;j++){\n                if(i == j) continue;\n                newarr[k] = nums[j];\n                k++;\n            }\n            long maxbyremove = lcmarr(newarr) * gcdarr(newarr);\n            maxans = Math.max(maxans, maxbyremove);\n        }\n        return maxans;\n    }\n\n    public long gcd(long a, long b){\n       while(b!=0){\n           long c = a%b;\n           a=b;\n           b=c;\n       }\n        return a;\n    }\n     public long lcm(long a, long b){\n       return (a*b)/gcd(a,b);\n    }\n    public long gcdarr(int[] arr){\n        long ans = arr[0];\n        for(int i =1;i<arr.length;i++){\n            ans = gcd(ans, arr[i]);\n        }\n        return ans;\n    }\n\n    public long lcmarr(int[] arr){\n        long ans = arr[0];\n        for(int i =1; i<arr.length;i++){\n            ans = lcm(ans, arr[i]);\n        }\n        return ans;\n    }\n}\n```
['Java']