One test case gets passed and other got time limit error maybe.
Deepak and Primes
Hi @rhythm9
You are facing TLE because in the for loop where you are marking all number as p[i]=1 there you need to consider a fact that even numbers can never be prime. This will reduce complexity of your code. And also it is given than n<=5000000 so that prime array that you are making should be p[100000001].
Here is your corrected code :
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.