dp of size n+1 with inf, where n is the length of nums. Set dp[0] to 0.nums from index 0 to n-1.i, iterate from index 0 to i.j, check if the GCD of nums[j] and nums[i] is greater than 1.dp[i+1] to be the minimum of its current value and dp[j] + 1.dp[n] is still inf. If it is, return -1, indicating that a valid split is not possible.dp[n] as the minimum number of subarrays needed for a valid split.