Tap here to switch tabs
Problem
Submissions

Problem: Split the Array to Make Coprime Products

med
30 min
Try to solve the Split the Array to Make Coprime Products problem.

Statement

You are given a 00 indexed integer array nums of length n.

A split at index i, where 0≤0 \leq i ≤\leq n −2- 2, is considered valid if the product of the first i +1+ 1 elements is coprime with the product of the remaining n −- i −1- 1 elements. That is, the greatest common divisor of the product of nums[0] through nums[i] and the product of nums[i + 1] through nums[n - 1] is equal to 11.

Return the smallest index i that forms a valid split, or −1-1 if no valid split exists.

Note: Two integers are coprime if their greatest common divisor is equal to 11.

Constraints:

  • n == nums.length

  • 1≤1 \leq n ≤104\leq 10^4

  • 1≤1 \leq nums[i] ≤106\leq 10^6

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Split the Array to Make Coprime Products

med
30 min
Try to solve the Split the Array to Make Coprime Products problem.

Statement

You are given a 00 indexed integer array nums of length n.

A split at index i, where 0≤0 \leq i ≤\leq n −2- 2, is considered valid if the product of the first i +1+ 1 elements is coprime with the product of the remaining n −- i −1- 1 elements. That is, the greatest common divisor of the product of nums[0] through nums[i] and the product of nums[i + 1] through nums[n - 1] is equal to 11.

Return the smallest index i that forms a valid split, or −1-1 if no valid split exists.

Note: Two integers are coprime if their greatest common divisor is equal to 11.

Constraints:

  • n == nums.length

  • 1≤1 \leq n ≤104\leq 10^4

  • 1≤1 \leq nums[i] ≤106\leq 10^6