java.lang.Object
g1201_1300.s1250_check_if_it_is_a_good_array.Solution

public class Solution extends Object
1250 - Check If It Is a Good Array.<p>Hard</p> <p>Given an array <code>nums</code> of positive integers. Your task is to select some subset of <code>nums</code>, 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 <code>1</code> from the array by any possible subset and multiplicand.</p> <p>Return <code>True</code> if the array is **good **otherwise return <code>False</code>.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> nums = [12,5,7,23]</p> <p><strong>Output:</strong> true</p> <p><strong>Explanation:</strong> Pick numbers 5 and 7. 5*3 + 7*(-2) = 1</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> nums = [29,6,10]</p> <p><strong>Output:</strong> true</p> <p><strong>Explanation:</strong> Pick numbers 29, 6 and 10. 29*1 + 6*(-3) + 10*(-1) = 1</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> nums = [3,6]</p> <p><strong>Output:</strong> false</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= nums.length <= 10^5</code></li> <li><code>1 <= nums[i] <= 10^9</code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • isGoodArray

      public boolean isGoodArray(int[] nums)