Tap here to switch tabs
Problem
Submissions

Problem: Minimum Stability Factor of Array

med
30 min
Try to solve the Minimum Stability Factor of Array problem.

Statement

You are given an integer array nums and an integer maxC.

A subarray of nums is called stable if the greatest common divisor of all elements in the subarray is strictly greater than 11. The stability factor of nums is the maximum length of a stable subarray in nums.

You may change at most maxC elements of nums to any positive integers.

Return the minimum possible stability factor of nums after performing at most maxC modifications.

Constraints:

  • 1≤n==1 \leq n == nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤109\leq 10^9

  • 0≤0 \leq maxC ≤n\leq n

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Stability Factor of Array

med
30 min
Try to solve the Minimum Stability Factor of Array problem.

Statement

You are given an integer array nums and an integer maxC.

A subarray of nums is called stable if the greatest common divisor of all elements in the subarray is strictly greater than 11. The stability factor of nums is the maximum length of a stable subarray in nums.

You may change at most maxC elements of nums to any positive integers.

Return the minimum possible stability factor of nums after performing at most maxC modifications.

Constraints:

  • 1≤n==1 \leq n == nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤109\leq 10^9

  • 0≤0 \leq maxC ≤n\leq n