Sum Of Prime
Medium Accuracy: 43.4% Submissions: 991 Points: 4

Given a number N,  find if can be expressed as a + b  such that a and b are prime.
Note: If [a, b] is one solution with a <= b, and [c, d] is another solution with c <= d, and a < c then  [a, b] is considered as our answer.


Example 1:

N = 8
3 5
3 and 5 are both prime and they
add up to 8.

Example 2:

N = 3
-1 -1
There are no solutions to the number 3.


Your Task:
You don't need to read input or print anything. Your task is to complete the function getPrimes() which takes an integer n as input and returns (a,b) as an array of size 2. 
Note: If no value of (a,b) satisfy the condition return (-1,-1) as an array of size 2.


Expected Time Complexity: O(N*loglog(N))
Expected Auxiliary Space: O(N)


3 <= N <= 106

We are replacing the old Disqus forum with the new Discussions section given below.
Click here to view old Disqus comments.

to report an issue on this page.


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


All Submissions

My Submissions:

Login to access your submissions.

Sum Of Prime

Output Window