Tap here to switch tabs
Problem
Submissions

Problem: Count Prime-Gap Balanced Subarrays

med
30 min
Try to solve the Count Prime-Gap Balanced Subarrays problem.

Statement

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

A subarray of nums is called prime gap balanced if:

  • It contains at least 22 prime numbers.

  • The difference between the maximum prime number and the minimum prime number in the subarray is at most k.

Return the total number of prime gap balanced subarrays in nums.

Note: A subarray is a contiguous non empty sequence of elements within an array.

Constraints:

  • 1≤1 \leq nums.length ≤5imes104\leq 5 imes 10^4

  • 1≤1 \leq nums[i] ≤5imes104\leq 5 imes 10^4

  • 0≤0 \leq k ≤5imes104\leq 5 imes 10^4

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Prime-Gap Balanced Subarrays

med
30 min
Try to solve the Count Prime-Gap Balanced Subarrays problem.

Statement

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

A subarray of nums is called prime gap balanced if:

  • It contains at least 22 prime numbers.

  • The difference between the maximum prime number and the minimum prime number in the subarray is at most k.

Return the total number of prime gap balanced subarrays in nums.

Note: A subarray is a contiguous non empty sequence of elements within an array.

Constraints:

  • 1≤1 \leq nums.length ≤5imes104\leq 5 imes 10^4

  • 1≤1 \leq nums[i] ≤5imes104\leq 5 imes 10^4

  • 0≤0 \leq k ≤5imes104\leq 5 imes 10^4