Tap here to switch tabs
Problem
Submissions

Problem: Minimum Subarrays in a Valid Split

Minimum Subarrays in a Valid Split divides an integer array into contiguous parts. Each part’s endpoint values need a greatest common divisor above one. Return the fewest parts or no valid split.

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

Minimum Subarrays in a Valid Split divides an integer array into contiguous parts. Each part’s endpoint values need a greatest common divisor above one. Return the fewest parts or no valid split.

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