Tap here to switch tabs
Problem
Submissions

Problem: Minimum Subarrays in a Valid Split

med
30 min
Try to solve the Minimum Subarrays in a Valid Split problem.

Statement

You are given an integer array nums.

A split of nums into contiguous subarrays is valid if the greatest common divisor (gcd⁡\gcd) of the first element and the last element of every subarray is strictly greater than 11.

Return the minimum number of subarrays needed to form a valid split. If no valid split exists, return −1-1.

Constraints:

  • 1≤1 \leq nums.length ≤1000\leq 1000

  • 1≤1 \leq nums[i] ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Subarrays in a Valid Split

med
30 min
Try to solve the Minimum Subarrays in a Valid Split problem.

Statement

You are given an integer array nums.

A split of nums into contiguous subarrays is valid if the greatest common divisor (gcd⁡\gcd) of the first element and the last element of every subarray is strictly greater than 11.

Return the minimum number of subarrays needed to form a valid split. If no valid split exists, return −1-1.

Constraints:

  • 1≤1 \leq nums.length ≤1000\leq 1000

  • 1≤1 \leq nums[i] ≤105\leq 10^5