Practice Split the Array to Make Coprime Products
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
You are given a 0-indexed integer array nums of length n. A split at an index i where 0 <= i <= n - 2 is called valid if the product of the first i + 1 elements and the product of the remaining elements are coprime. Return the smallest index i at which the array can be split validly or -1 if there is no such split. Two values val1 and val2 are coprime if gcd(val1, val2) == 1 where gcd(val1, val2) is the greatest common divisor of val1 and val2.
Source: Split the Array to Make Coprime Products on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
nums = [4,7,8,15,3,5]
2
# Example 2
nums = [4,7,15,8,3,5]
-1
Constraints
Related LeetCode Problems
Practice more problems similar to Split the Array to Make Coprime Products.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.