![]() |
VOOZH | about |
Given two integers L and R, the task is to find the minimum difference between any two prime numbers in the range [L, R].
Examples:
Input: L = 21, R = 50
Output: 2
(29, 31) and (41, 43) are the only valid pairs
that give the minimum difference.Input: L = 1, R = 11
Output: 1
The difference between (2, 3) is minimum.
Approach:
Below is the implementation of the above approach:
2
Time Complexity: O((R - L) + sqrt(105))
Auxiliary Space: O(105)