Skip to content

Practice Check If It Is a Good Array

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#1250
LeetCode Problem

Check If It Is a Good Array

Problem Statement

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. Return True if the array is good otherwise return False.

Source: Check If It Is a Good Array on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [12,5,7,23]
Output
true

# Example 2

Input
nums = [29,6,10]
Output
true

# Example 3

Input
nums = [3,6]
Output
false

Constraints

1 <= nums.length <= 10^5
1 <= nums[i] <= 10^9

Related LeetCode Problems

Practice more problems similar to Check If It Is a Good Array.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.