3334. Find the Maximum Factor Score of Array Medium

@problem@discussion
#Array#Math#Number Theory



1/**
2 * [3334] Find the Maximum Factor Score of Array
3 *
4 * You are given an integer array nums.
5 * The factor score of an array is defined as the product of the LCM and GCD of all elements of that array.
6 * Return the maximum factor score of nums after removing at most one element from it.
7 * Note that both the <span data-keyword="lcm-function">LCM</span> and <span data-keyword="gcd-function">GCD</span> of a single number are the number itself, and the factor score of an empty array is 0.
8 *  
9 * <strong class="example">Example 1:
10 * <div class="example-block">
11 * Input: <span class="example-io">nums = [2,4,8,16]</span>
12 * Output: <span class="example-io">64</span>
13 * Explanation:
14 * On removing 2, the GCD of the rest of the elements is 4 while the LCM is 16, which gives a maximum factor score of 4 * 16 = 64.
15 * </div>
16 * <strong class="example">Example 2:
17 * <div class="example-block">
18 * Input: <span class="example-io">nums = [1,2,3,4,5]</span>
19 * Output: <span class="example-io">60</span>
20 * Explanation:
21 * The maximum factor score of 60 can be obtained without removing any elements.
22 * </div>
23 * <strong class="example">Example 3:
24 * <div class="example-block">
25 * Input: <span class="example-io">nums = [3]</span>
26 * Output: 9
27 * </div>
28 *  
29 * Constraints:
30 * 
31 * 	1 <= nums.length <= 100
32 * 	1 <= nums[i] <= 30
33 * 
34 */
35pub struct Solution {}
36
37// problem: https://leetcode.com/problems/find-the-maximum-factor-score-of-array/
38// discuss: https://leetcode.com/problems/find-the-maximum-factor-score-of-array/discuss/?currentPage=1&orderBy=most_votes&query=
39
40// submission codes start here
41
42impl Solution {
43    pub fn max_score(nums: Vec<i32>) -> i64 {
44        
45    }
46}
47
48// submission codes end
49
50#[cfg(test)]
51mod tests {
52    use super::*;
53
54    #[test]
55    fn test_3334() {
56    }
57}
58


Back
© 2025 bowen.ge All Rights Reserved.