2521. Distinct Prime Factors of Product of Array Medium
1/**
2 * [2521] Distinct Prime Factors of Product of Array
3 *
4 * Given an array of positive integers nums, return the number of distinct prime factors in the product of the elements of nums.
5 * Note that:
6 *
7 * A number greater than 1 is called prime if it is divisible by only 1 and itself.
8 * An integer val1 is a factor of another integer val2 if val2 / val1 is an integer.
9 *
10 *
11 * <strong class="example">Example 1:
12 *
13 * Input: nums = [2,4,3,7,10,6]
14 * Output: 4
15 * Explanation:
16 * The product of all the elements in nums is: 2 * 4 * 3 * 7 * 10 * 6 = 10080 = 2^5 * 3^2 * 5 * 7.
17 * There are 4 distinct prime factors so we return 4.
18 *
19 * <strong class="example">Example 2:
20 *
21 * Input: nums = [2,4,8,16]
22 * Output: 1
23 * Explanation:
24 * The product of all the elements in nums is: 2 * 4 * 8 * 16 = 1024 = 2^10.
25 * There is 1 distinct prime factor so we return 1.
26 *
27 *
28 * Constraints:
29 *
30 * 1 <= nums.length <= 10^4
31 * 2 <= nums[i] <= 1000
32 *
33 */
34pub struct Solution {}
35
36// problem: https://leetcode.com/problems/distinct-prime-factors-of-product-of-array/
37// discuss: https://leetcode.com/problems/distinct-prime-factors-of-product-of-array/discuss/?currentPage=1&orderBy=most_votes&query=
38
39// submission codes start here
40
41impl Solution {
42 pub fn distinct_prime_factors(nums: Vec<i32>) -> i32 {
43 0
44 }
45}
46
47// submission codes end
48
49#[cfg(test)]
50mod tests {
51 use super::*;
52
53 #[test]
54 fn test_2521() {
55 }
56}
57
Back
© 2025 bowen.ge All Rights Reserved.