code is giving TLE is there any more efficient approach
More efficient approach?
hey @Vinayak-Jaiswal-2235522119878218, you can’t allocate space for 10^9 size array, so just make it 10^8 and you will get the successful submissition.
Hope this resolved your doubt.
Plz mark the doubt as reoslved in my doubts section. 
but why we cant allocate 10^9
If you calculate space requirements, it will require 4 GB of ram. which is quite high for a single program to run. And on the backend there are mulitple such codes being run at the same time.
Hope this resolved your doubt.
Plz mark the doubt as reoslved in my doubts section. 
but what if we have n=10^9
Hey @Vinayak-Jaiswal-2235522119878218, there’s no such case in the test case file. But if you still want to do so, there’s something called segmented sieve, read about it and you have to use that.