Loading...
You are given a list of inclusive integer ranges ranges, where each ranges[i] = [l, r] covers every integer from l to r.
Return how many distinct prime numbers are covered by at least one range. A prime counted by several overlapping ranges is still counted only once.
Input: ranges = [[2,10]]
Output: 4
Explanation: The primes in [2, 10] are 2, 3, 5, and 7.
Input: ranges = [[2,10],[8,20]]
Output: 8
Explanation: The union covers [2, 20]; its primes are 2, 3, 5, 7, 11, 13, 17, 19.
Input: ranges = [[14,16]]
Output: 0
Explanation: 14, 15, and 16 are all composite.
ranges.length ≤104ranges[i].length =2Click "Run" to test with sample cases or "Submit" to run all tests.