2436. Minimum Split Into Subarrays With GCD Greater Than One
You are given an array nums consisting of positive integers.
Split the array into one or more disjoint subarrays such that:
- Each element of the array belongs to exactly one subarray, and
- The GCD of the elements of each subarray is strictly greater than 1.
Return the minimum number of subarrays that can be obtained after the split.
Note that:
- The GCD of a subarray is the largest positive integer that evenly divides all the elements of the subarray.
- A subarray is a contiguous part of the array.
1 | class Solution { |