Rust beginner 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: 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```rust []\nimpl Solution {\n    pub fn max_score(nums: Vec<i32>) -> i64 {\n        // special case 1\n        if nums.is_empty() {\n            return 0;\n        }\n        // precision conversion\n        let nums: Vec<i64> = nums.iter().map(|v| *v as i64).collect();      \n        // special case 2\n        if nums.len() == 1 {\n            return nums[0] * nums[0];\n        }\n\n        // pre-compute the gcd prefix and suffix array\n        // time: O(n)\n        let n = nums.len();\n        // gcd_prefix[i] stores the gcd up to nums[i]\n        let mut gcd_prefix = vec![1; n];\n        gcd_prefix[0] = nums[0];\n        for i in 1..n {\n            gcd_prefix[i] = Self::gcd(gcd_prefix[i - 1], nums[i]);\n        }\n        // gcd_suffix[i] stores the gcd from nums[i] to end\n        let mut gcd_suffix = vec![1; n];\n        gcd_suffix[n - 1] = nums[n - 1];\n        for i in (0..n - 1).rev() {\n            gcd_suffix[i] = Self::gcd(gcd_suffix[i + 1], nums[i]);\n        }\n\n        // precompute lcm prefix and suffix array\n        // time: O(n)\n        let mut lcm_prefix = vec![1; n];\n        // lcm_prefix[i] stores the lcm up to nums[i]\n        lcm_prefix[0] = nums[0];\n        for i in 1..n {\n            lcm_prefix[i] = Self::lcm(lcm_prefix[i - 1], nums[i]);\n        }\n        // lcm_suffix[i] stores the lcm from nums[i] to end\n        let mut lcm_suffix = vec![1; n];\n        lcm_suffix[n - 1] = nums[n - 1];\n        for i in (0..n - 1).rev() {\n            lcm_suffix[i] = Self::lcm(lcm_suffix[i + 1], nums[i]);\n        }\n\n        // gcd_exclude[i] stores the gcd excluding nums[i]\n        // lcm_exclude[i] stores the lcm excluding nums[i]\n        let mut gcd_exclude = vec![1; n];\n        let mut lcm_exclude = vec![1; n];\n        for i in 0..n {\n            // corner cases\n            if i == 0 {\n                gcd_exclude[i] = gcd_suffix[1];\n                lcm_exclude[i] = lcm_suffix[1];\n            } else if i == n - 1 {\n                gcd_exclude[i] = gcd_prefix[n - 2];\n                lcm_exclude[i] = lcm_prefix[n - 2];\n            } else {\n                gcd_exclude[i] = Self::gcd(gcd_prefix[i - 1], gcd_suffix[i + 1]);\n                lcm_exclude[i] = Self::lcm(lcm_prefix[i - 1], lcm_suffix[i + 1]);\n            }\n        }\n\n        // start iteration\n        // time: O(n)  \n        // store the score when nothing is removed\n        let mut max_score = match gcd_prefix[n - 1] {\n            0 => 0,\n            s => lcm_prefix[n - 1].abs() * s,\n        };\n        for i in 0..n {\n            // compute the score when nums[i] is removed\n            let new_score = lcm_exclude[i] * gcd_exclude[i];\n            max_score = max_score.max(new_score);\n        }\n        max_score\n    }\n\n    pub fn gcd(a: i64, b: i64) -> i64 {\n        let mut a = a;\n        let mut b = b;\n        // gcd using euclidean algorithm\n        while b != 0 {\n            (a, b) = (b, a % b);\n        }\n        a\n    }\n\n    pub fn lcm(a: i64, b: i64) -> i64 {\n        if a == 0 || b == 0 {\n            return 0;\n        }\n        (a * b).abs() / Self::gcd(a, b)\n    }\n}\n```
['Rust']