Spit the array

Given an array A with N integers.

A good split is gcd(a[start],a[end]) > 1.

Split the array such that the whole array is good split.

The value of each element is used only once.The value of each element in the array should belong to a split.

Find the minimum number of splits required to split the array.

Example:
2 3 2 3 3 -> ans = 2
subarray[1,3] gcd(2,2)
and
subarray[4,5] gcd(3,3)

2 Likes