The Prime Twins
Easy Accuracy: 47.64% Submissions: 254 Points: 2

Given two positive numbers L and R (L < R), find out the smallest twins in the range [L , R].Two numbers are twins if they are prime numbers and difference between them is 2.

Example 1:

Input: L = 0, R = 5
Output: [3, 5]
Explanation: Difference between 3 and 5 is 2
and also these two are smallest prime in range.
So the answer is 3, 5.


Example 2:

Input: L = 5, R = 10
Output: [5, 7]
Explanation: Difference between 5 and 7 is 2
and also these two are smallest prime in range.
So the answer is 5, 7.


You dont need to read input or print anything. Complete the function primeTwins() which takes L and R as input parameter and returns a pair if exist else returns -1.

Expected Time Complexity: O(nloglogn)
Expected Auxiliary Space: O(n)

Constraints:
0<= L <=500
2<= R <=1000

We are replacing the old Disqus forum with the new Discussions section given below.

### Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

#### My Submissions:  