https://ide.codingblocks.com/s/286242 my code is giving tle?
Deepak and Primes
Your code will also give segmentation fault.
Because according to the constraints, you have to check primes till 10^7
You can refer this https://ide.codingblocks.com/s/285203
why have u declared array globally?
Because if you declare the array of size 10^7 locally, then it will give a segmentation fault.
Maximum size of a local integer array you can make is of order 10^6.
But if if you declare it globally maximum size is of order 10^7
instead of a boolean array can’t we take a integer array?
u can take int array
its just that since we are storing 0 or 1
so boolean array would take less space hence boolean array is used
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.