1250. Check If It Is a Good Array Hard

@problem@discussion
#Array#Math#Number Theory



1/**
2 * [1250] Check If It Is a Good Array
3 *
4 * Given an array nums of positive integers. Your task is to select some subset of nums, multiply each element by an integer and add all these numbers. The array is said to be good if you can obtain a sum of 1 from the array by any possible subset and multiplicand.
5 * Return True if the array is good otherwise return False.
6 *  
7 * Example 1:
8 * 
9 * Input: nums = [12,5,7,23]
10 * Output: true
11 * Explanation: Pick numbers 5 and 7.
12 * 5*3 + 7*(-2) = 1
13 * 
14 * Example 2:
15 * 
16 * Input: nums = [29,6,10]
17 * Output: true
18 * Explanation: Pick numbers 29, 6 and 10.
19 * 29*1 + 6*(-3) + 10*(-1) = 1
20 * 
21 * Example 3:
22 * 
23 * Input: nums = [3,6]
24 * Output: false
25 * 
26 *  
27 * Constraints:
28 * 
29 * 	1 <= nums.length <= 10^5
30 * 	1 <= nums[i] <= 10^9
31 * 
32 */
33pub struct Solution {}
34
35// problem: https://leetcode.com/problems/check-if-it-is-a-good-array/
36// discuss: https://leetcode.com/problems/check-if-it-is-a-good-array/discuss/?currentPage=1&orderBy=most_votes&query=
37
38// submission codes start here
39
40impl Solution {
41    pub fn is_good_array(nums: Vec<i32>) -> bool {
42        false
43    }
44}
45
46// submission codes end
47
48#[cfg(test)]
49mod tests {
50    use super::*;
51
52    #[test]
53    fn test_1250() {
54    }
55}
56


Back
© 2025 bowen.ge All Rights Reserved.