Practice Minimum Stability Factor of Array
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Minimum Stability Factor of Array
Problem Statement
You are given an integer array nums and an integer maxC. A subarray is called stable if the highest common factor (HCF) of all its elements is greater than or equal to 2. The stability factor of an array is defined as the length of its longest stable subarray. You may modify at most maxC elements of the array to any integer. Return the minimum possible stability factor of the array after at most maxC modifications. If no stable subarray remains, return 0.
Source: Minimum Stability Factor of Array on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
nums = [3,5,10], maxC = 1
1
# Example 2
nums = [2,6,8], maxC = 2
1
# Example 3
nums = [2,4,9,6], maxC = 1
2
Constraints
Related LeetCode Problems
Practice more problems similar to Minimum Stability Factor of Array.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.