I applied seive algo but it is giving me TLE in test case 0 ,is there any another solution for the same???
Prime vist using seive algo giving TLE for test case 0
@firozbhaikardar21
hello Firoz,
preprocess ur sieve array and store number of primes from 1 to i at index i.
you can do it easily.
let say prime[i] is telling u number primes till index i using this info u can work for index i+1 by doing something as follows.
a) if i+1 is prime then
prime[i+1]=1+prime[i]
b) otherwise
prime[i+1]=prime[i]
@firozbhaikardar21
also checkout this tutorial by prateek bhaiya - https://www.youtube.com/watch?v=8sniiDbfPK4
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.
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.