Practice Count Prime-Gap Balanced Subarrays
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Medium#3589
LeetCode ProblemCount Prime-Gap Balanced Subarrays
Problem Statement
Given nums and k, count nonempty contiguous subarrays containing at least two prime entries for which the largest prime value minus the smallest prime value is at most k. Other nonprime entries are allowed. Return the count.
Source: Count Prime-Gap Balanced Subarrays on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
nums = [1,2,3], k = 1
Output
2
# Example 2
Input
nums = [2,3,5,7], k = 3
Output
4
Constraints
1 <= nums.length <= 5 * 10^4
1 <= nums[i] <= 5 * 10^4
0 <= k <= 5 * 10^4
Related LeetCode Problems
Practice more problems similar to Count Prime-Gap Balanced Subarrays.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.